Mutation challenge - Is this correct?

SPOILER ALERT
Solution of the challenge below

I solved the challenge with this code.

function mutation(arr) {
    return arr[1].toLowerCase().split('').every(elem => arr[0].toLowerCase().includes(elem))
}

I’ve seen few solutions wich uses indexOf() method. (Freecodecamp hint also mentioned it). I want to know if the above code will work good aswell.

I tried to solve with RegExp first but could not do it, It is possible?

You say that you solved the challenge, so it seems apparent that your solution does work.

1 Like

Hi @LuigiDerson,

This is the exact approach I used to solve the problem, looks great.

Regex could work, but is not necessary here. toLowerCase() method is cleaner and easier to work with. I try to avoid regex for simple problems like this.

1 Like