JSFiddle - React, Tailwind, and code Playground
JavaScript
var a = [ { "id": 10, "nice_name": "Bill" },
{ "id": 12, "nice_name": "Dan"},
{ "id": 18, "nice_name": "Tony" },
{ "id": 19, "nice_name": "Sam" },
]
var input = [10, 19];
var size = a.length; //a -> your array
var inputSize = input.length; // -> the search array
var thePeople = []; //where you will store the names that match
for(var i = 0; i < size; i++) { //cycle your array
for(var j = 0; j < inputSize; j++) { //cycle the search array
if(a[i].id === input[j]) { //check if there is a match on id
thePeople.push(a[i].nice_name); //save the name into a new array
}
}
}
console.log(thePeople);