Tell us what’s happening:
Hello everybody, I’ve come across this challenge and I get stuck, the browser keeps throwing this Error: TypeError: unknown: Cannot read property ‘0’ of undefined.
Could you please show me what the problem is in my code? Thanks so much.
Your code so far
function mutation(arr) {
"use strict"
let secondArray = arr[1].toLowerCase().split('');
let firstArray = arr[0].toLowerCase().split('');
for (let i = 0; i < firstArray.length; i++)
if (secondArray.indexOf(firstArray[i]) === -1)
return false;
return true;
}
mutation(["hello", "hey"]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations/