Can;t get this to work: Check For The Presence of an Element With indexOf()

Tell us what’s happening:

I can’t seem to solve this one :frowning:

Your code so far

function quickCheck(arr, elem) {
// Only change code below this line
if (arr.indexOf("") && if elem.indexOf("")) ;
return true;
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/84.0.4147.135 Safari/537.36.

Challenge: Check For The Presence of an Element With indexOf()

Link to the challenge:


The syntax for the .indexOf method is array.indexOf(element). This method returns the first index in array where element occurs. If the element is not present in array, this method returns -1.

Hope this helps! If you need an example, let me know. :slight_smile:

1 Like

do not put a semicolon on every line. In this position you are ending the if statement there

I think you are getting syntax issues there