Basic Algorithm Scripting - Mutations

Good day people.
so far i have passed a few tests but i seem to be failing the one with " Failed:mutation(["Alien", "line"]) should return true."

any hints would be appreciated.
Your code so far

function mutation(arr) {
const lower = [];

arr.forEach(element => {
lower.push(element.toLowerCase());
//making everything lowercase
});

let firstelement = lower[0];
let secondelemnt = lower[1];
//Seperating arrays into their own variable
for (let i = 0; i < arr.length; i ++){//iterating through array
if(secondelemnt.indexOf(firstelement[i]) < 0){//comparing the arrays
      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/104.0.0.0 Safari/537.36

Challenge: Basic Algorithm Scripting - Mutations

Link to the challenge:

Why are you iterating this array arr? What are the values of teh variables firstelement and secondelemnt?

The challenge says:

Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

And, how do you iterate a variable with a string value?

the values of firstelement will be the first array [0] in lower case .
reason for iteration is to excecate the condition which is the if statement for the amount of elements there are

You are iterating the array, arr. What is its length? And how many times you want to iterate?

ok thank you so much for your input

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.