my problem is to update an array , containing objects , and each object contains array , i want to update the global array , with values refering to array inside objects , this logic !
generalArray = [{name:String, features:String[]}]
// Try edit message
let array1 = [{ name: "num", features: ['id'] },
{ name: "cat", features: ['gender'] }];
ob = {name:'num2', features:['id']};
function updateArr(arr,ob){
const index = arr.findIndex(x =>
ob.features.toString() === x.features.toString()
);
if (index === -1) {
arr.push(ob);
} else {
arr[index] = ob;
}
}
console.log(array1);
updateArr(array1,ob);
console.log(array1);
this is working perfectly when features array of any object contains one string , but if it contains more than one string , exm features=['id','gender' ] it can't do anything ! help please and thanks