I have two arrays, one is a simple array like this:
["Adrian", "Jhon"]
And the another array is an array of objects which I converted from a jSon object. The original jSon was this:
[
{
"Nome": "Jhon",
"Departamento": "Test"
},
{
"Nome": "Adrian",
"Departamento": "Test"
},
{
"Nome": "Jessy",
"Departamento": "Test"
}
]
Now I need to compare the first array, with second one. If the Nome attribute match with my first array, I will return the entire object to another array of objects.
How can I do it with jQuery or pure JavaScript keeping the order of the first array?
EDIT - For stop taking downvotes
I already tried this:
jQuery.each(array, function (x) {
novoRepo.push(jQuery.grep(repositorio, function (a) {
return a.Nome == array[x];
}));
});
But I get an exception saying that a.Nome is undefined.