JavaScript string match from the array of the object (this is done by the map with the filter)

PHOTO EMBED

Thu May 04 2023 12:23:01 GMT+0000 (Coordinated Universal Time)

Saved by @Himanshu007 #javascript

let demoData = [
  [
    { name: "Himanshu", age: 30 },
    { name: "KK", age: 29 },
  ],
  [
    { name: "preyansh", age: 30 },
    { name: "aki", age: 29 },
  ],
];
let uName = "K";
let matched = [];
let notMatched = [];
let mapingData = demoData.map((element, index, array) => {
  return element.filter((innerEle) => {
    return (innerEle.name.toLowerCase().includes(uName.toLowerCase())) ? done.push(innerEle) : wrong.push(innerEle);
  })
});
console.log(done);
content_copyCOPY