There’s an error in the console that say’s “TypeError: “i” is read-only” but I don’t see where it’s trying to change i other than in the loop declaration.
Your code so far
function mutation (genes) {
// Sep stands for seperated, I did this for the alphabet test.
let genesSep = genes[1].split("");
// Len stands for length to check if all characters and in the first string
let correctLen = 0;
console.log(genesSep);
for (const i = 0; i < genesSep.length; i++) {
console.log(i)
if (genes[0].toLowerCase().includes(genesSep[i].toLowerCase())) {
correctLen++;
// To check if all characters are in the second string.
if (correctLen.length == genesSep.length) {
return true;
}
} else {
return false;
}
}
}
console.log(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/143.0.0.0 Safari/537.36 Edg/143.0.0.0
Challenge Information:
Implement the Mutations Algorithm - Implement the Mutations Algorithm
The thing I can’t figure out is where I’m trying to change it, if I remember right, it makes an exception for the declaration (not sure if that’s the right word, what I mean when I say that is the part after “for“:
).
And to answer @ILM ‘s question, I don’t actually know, I just thought it said that in one of the theory documents.
console.log(`CL: ${genesSep.length} ?CL: ${correctLen}`);
// To check if all characters are in the second string.
if (correctLen.length == genesSep.length) {