I don't know what's wrong in this if statement?

it should be false but it’s not !

  **Your code so far**

function mutation(arr) {
let array = [arr[0].toLowerCase(), arr[1].toLowerCase()]
for (let i = 0; i < array[1].length; i++) {
if (array[0].indexOf(array[1][i])) {
    return false;
return true
console.log(mutation(["Mary", "Army"]));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36

Challenge: Mutations

Link to the challenge:

What should be false? Why should it be false?

oops sorry not this one

this one mutation([“hello”, “neo”])

What should be causing that to return false?

1 Like

arr[0] letters should be match with arr[1] but in this case , this condition is false . I don’t know why but my code keep showing true.

What does indexOf() return?

which is stored inside the array

What does array[0].indexOf('n') return?

1 Like

it should be an error I guess ?!?!?

you can always check with console.log or check the documentation on the method, you never need to just guess

1 Like

yeah , it’s shows -1

is -1 truthy or falsy?

1 Like

-1 is falsy , but why are u asking this ?

no, it’s not falsy
only one number is falsy, and is not -1

1 Like

I’ve nothing to say .

do you understand why it’s failing now?

Also think about what indexOf() returns for the first element of an array.

it should be zero but I still don’t get why it’s failing

What do you want this logic to do? Can you explain it in English, rather than code?

1 Like