[Solved] Basic Algorithm Scripting: Mutations (ugly alternative solution)

[Solved] Basic Algorithm Scripting: Mutations (ugly alternative solution)
0

#1

Hello,

I search for alternative ways to solve the challenge, and this one

function mutation(arr) {
  let l = arr[1].length
  let c = 0;
  arr[1].split('').forEach((e) => {
    if (arr[0].includes(e.toLowerCase())) c++;
  });
  if (c === l) return true;
  return false;
}

fails the following tests:

mutation(["Mary", "Army"]) should return true.
mutation(["Mary", "Aarmy"]) should return true.

wondering why…


#2

because arr[0] does not include ‘m’ but ‘M’, I am guessing. Maybe convert the whole arr[0].toLowerCase().


#3

Super right, I forgot it, thank you… :man_facepalming: