Tell us what’s happening:
My code not producing what’s expected Your code so far
function quickCheck(arr, elem) {
// Only change code below this line
if (arr.indexOf(elem)){
return true;
}else{
return false;
}
// Only change code above this line
}
console.log(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'));
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36.
Challenge: Check For The Presence of an Element With indexOf()
insexOf() […] returns the position, or index, of that element, or -1 if the element does not exist on the array.
the issue here is that when the element is not present the method returns -1 which is truthy, and so you return true, when the element is present but at index 0 the method returns 0 which is falsy and you return false