Am I taking this challenge too seriously?
While my code does pass the challenge, I am wondering whether it should…
What if I test [“Hello”, “HHeelllllllo”] or [“abcZZZ”, “ZZZzzz”] ? It will return true.
Should it?
I have the feeling that only that many letters should be matched as there are in arr[0]…
The instructions do not specify this.
If I were to solve this again, I would remove every letter in arr[0] that has been matched. How that will be achieved, I have yet to work out.
Did anyone have the same issue and managed to solve it? If so, could you give me a nudge in the right direction?
Thank you and stay healthy.
My code so far
function mutation(arr) {
const searchInArr = arr[0].toLowerCase();
const searchForArr = arr[1].toLowerCase().split('');
return searchForArr.every((letter) => searchInArr.indexOf(letter) >= 0);
}
console.log(mutation(["hello", "ll"]));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36 Edg/88.0.705.50.
Challenge: Mutations
Link to the challenge: