find property value in an array of objects javascript

You can use Array.prototype.some as follows.

var objArr = [
  {
  "7364234": "hsjd",
  "errorCode": "400"
  },
  {
  "12345": "jd",
  "errorCode": "500-001"
  }
];

const contains = (keyVal) => objArr.some(({ errorCode }) => errorCode.includes(keyVal));
console.log(contains("500"));

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top