Hello. I have this code:
function quickCheck(arr, elem) {
// change code below this line
if(arr.indexOf(elem)) {
return true;
}
else if(arr.indexOf(elem) === -1){
return false;
}
// change code above this line
}
// change code here to test different cases:
console.log(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'));
I get errors:
quickCheck(["squash", "onions", "shallots"], "mushrooms")
should return
false
quickCheck(["onions", "squash", "shallots"], "onions")
should return
true
quickCheck([true, false, false], undefined)
should return
false
Any ideas why my code does not work?