Check For The Presence of an Element With indexOf() / quickcheck challenge

Basically, I am just wondering why my code won’t pass the challenge. When I console.log at the end, my code returns true and false in a way that matches the challenge’s requirements specify. When I try to submit, only the very last requirement gets approved.

Your code so far

function quickCheck(arr, elem) {
// Only change code below this line
let resultOne = arr.indexOf(elem);
if (resultOne == -1){
return “false”
}
else if (resultOne => 0) {
return “true”
}

// Only change code above this line
}

console.log(quickCheck([true, false, false], undefined))


function quickCheck(arr, elem) {
// Only change code below this line
let resultOne = arr.indexOf(elem);
if (resultOne == -1){ 
   return "false"
 }
 if (resultOne => 0) {
   return "true"
 }
 

// Only change code above this line
}

console.log(quickCheck([true, false, false], undefined))



Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36.

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

Link to the challenge:

Hello~!

Two issues I see:

This is not correct comparison syntax - it is >= not =>.

You are returning a string with the value “false”, rather than returning the boolean false.

It looks like fixing these should get you passing. :slight_smile:

3 Likes

Solved. Thank you for the quick fix!

I am confused what is this

Hello!

That is a JavaScript function which @pdh98 wrote to check if an array contains a specific element.

What are you confused about? Perhaps we can clarify for you!

Hello~!

I am confused by your reply. Did you have a question that I could assist you with?