Let's say I have an object of
var people = [
{name: 'John'}, // 0
{name: 'James'}, // 1
{name: 'Sue'}, // 2
{name: 'Mary'}, // 3
{name: 'Will'}, // 4
{name: 'Lukas'}, // 5
{name: 'Sam'} // 6
];
and then I have this array: var history = [0, 2, 4, 6]; // we have John, Sue, Will and Sam
Using Lodash, or general JavaScript, how can I make it to return true
or false
if a entered value is found inside the history[]
array.
For example, isInHistoryArray(5)
would return false
but isInHistoryArray(2)
would return true