1
I have the following problem, in my scenario I am capturing the Ids of a checkbox, I have a list of JSON objects where I need to compare these Ids with the Ids from the list of JSON objects. The problem is that they have different sizes.
My Code
var obj = [
{ "Id": 1, "Nome": "José" },
{ "Id": 2, "Nome": "João"},
{ "Id": 3, "Nome": "Maria"}
];
var ids = [1, 2];
var j = 0;
var usuarios = [];
for(var i = 0; i < obj.lenght; i++){
j++;
if(obj[i].Id == ids[j]){
usuarios.push(obj[i]);
}
}
console.log(usuarios);
Vlw, you helped a lot.
– William
Blz... I added a second solution that I found even better.
– Sam