Check For The Presence of an Element With indexOf()
Summary
indexOf()
can be used to find the index of a specific array.
Final Code
function quickCheck(arr, elem) {
// Only change code below this line
if (arr.indexOf(elem) === -1) {
return false;
} else {
return true;
}
// Only change code above this line
}
console.log(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'));