In JavaScript if I have this value in a variable...
var selectedId = '2';
And I have this array of objects below....
var itemsArray = [
{
id: 1,
name: 'Item 1',
},
{
id: 2,
name: 'Item 2',
},
{
id: 3,
name: 'Item 3',
},
{
id: 4,
name: 'Item 4',
},
];
How can I get the itemsArray name value from the object that the value selectedId has.
In this example I would have the value of 2 in selectedId and need to get the itemsArray[n][name] of Item 2