mutation([“hello”, “hey”]);
we wish to know if the letters in “hey”
can be found in “hello” so in my code I
Iooped through “hey” checking to see if
“hello”. includes( each letter letter in “hey”)
if it is found that a letter is not includes
then return false else return true
this can be done by setting var ret=true;
before starting the loop
only change ret to false is a letter
is not found so if all the letters are found
ret remains true
the last line must return ret;
Thanks. That helps a lot. Certain parts are still not passing, but This is how I set up the return so that it doesn’t immediately end the checking of the loop. Am I returning in the wrong spot?
let answer = true;
let stringToCheck = arr[0].toLowerCase();
let stringToMatch = arr[1].toLowerCase();
for(let i = 0; i < stringToMatch.length; i ++){ {
if(stringToCheck[i].includes(stringToMatch[i])){
answer = false;
}
}
}
return answer;
}
console.log(mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]))
console.log(mutation(["hello", "Hello"]));
thank you for your patience guys. I feel like I didn’t earn this one with all the help i’ve needed.
Thank you both. Just got back from work and am back into this wretched problem. That makes sense @ILM to check the entire string to see if it includes the letter. @Da_vey I think I understand that I need to use the NOT operator to see if a string does not include the letter found in the second argument, yes? or no? I put it in the [0] position to return false if no letters are found and true else-wise. I am passing more tests for the challenge but … [‘voodoo’, ‘no’] and [
‘hello’, ‘neo’] should be showing false. Am I any closer to solving this crazy problem?
let answer = true;
let stringToCheck = arr[0].toLowerCase();
let stringToMatch = arr[1].toLowerCase();
for(let i = 0; i < stringToMatch.length; i ++){
if(!stringToCheck.includes(stringToMatch[i])){
answer = false;
} else {
answer = true;
}
}
return answer;
}
console.log(mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]));
console.log(mutation(["hello", "hey"]));
console.log(mutation(["voodoo", "no"]));
console.log(mutation(["hello", "neo"]));```
@Da_vey You are the man. Halle-freaking-lujah!!! Finally got it to pass. That was insanely difficult. Could not have done that without your extreme patience. Thanks guys, you rock!!!