记录重复(错误1062)

时间:2018-07-09 02:09:33

标签: php

大家早上好。请问这段代码有什么问题?我已经在stackoverflow上尝试过关于重复条目的所有解决方案,但是没有任何效果。这是代码。

function whatIsInAName(collection, source) {
  const [[findKey, findVal]] = Object.entries(source);
  return collection.filter(el => (
    Object.entries(el).some(([key, val]) => (
      key === findKey && val === findVal
    )
  )))
}
console.log(
  whatIsInAName([{
    first: "Romeo",
    last: "Montague"
  }, {
    first: "Mercutio",
    last: null
  }, {
    first: "Tybalt",
    last: "Capulet"
  }, {
    first: "another",
    last: "Capulet"
  }, {
    first: "Tybalt",
    last: "notACapulet"
  }], {
    last: "Capulet"
  })
);

0 个答案:

没有答案