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: