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


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…

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

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