Ian.M
1
Just not sure whats wrong here
Your code so far
function mutation(arr) {
let source = arr[0].toLowerCase();
let mutant = arr[1].toLowerCase();
let sourceArr = arr[0].split(" ")
let mutantArr = arr[1].split(" ")
let count = 0;
for(let i = 0; i < mutant.length; i += 1 ){
let check = mutant[i];
if(source.includes(check)){
count= count + 1
}
}
if(count === mutant.length){
return true
}
return false;
}
mutation(["hello", "hey"]);
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
Challenge: Basic Algorithm Scripting - Mutations
Link to the challenge:
I’m not immediately sure either. Have you tried console logging intermediate results?
Ian.M
3
it works for all things false
Have you tried logging out intermediate variables? Do the arrays hold what you expect?
Ian.M
5
yea each variable is as desired… i havent confirmed the functionality of the syntax for to lower case in this context… im gonna look now
What’s in those arrays after you split? I’m suspicious
Ian.M
7
strings… hahaha containing the full word
it never split like i intended… why?
Ian.M
8
but the rest of the code still seems to work with it
I don’t think it worksas you intend if it not an array of letters
Ian.M
10
check still is “h” then “e” then “y”
Ian.M
11
unless its because .includes() works differently
Oh, you aren’t using those arrays. I’d delete them.
1 Like
Ian.M
13
why isnt any of them returning true ??

What’s count for one of those tests?
Ian.M
15
for hey the count is 2 …
Ian.M
16
console.log(mutation([“ate”, “date”]))
//count 0 1 2 3 false
What about a case that is supposed to be true?
Ian.M
18
i actually resolved it… thanks forthe guidance and the making me not feel alone. helps a lot
1 Like
Ian.M
19
can i show it here to you?
do you not really need to see it?
haha
would you wanna see what it ended up being?