Files

2.3 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
af2170cad53daa0770fabdea Mutations 1 16025 mutations

--description--

Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

For example, ["hello", "Hello"], should return true because all of the letters in the second string are present in the first, ignoring case.

The arguments ["hello", "hey"] should return false because the string hello does not contain a y.

Lastly, ["Alien", "line"], should return true because all of the letters in line are present in Alien.

--hints--

mutation(["hello", "hey"]) should return false.

assert.isFalse(mutation(['hello', 'hey']));

mutation(["hello", "Hello"]) should return true.

assert.isTrue(mutation(['hello', 'Hello']));

mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]) should return true.

assert.isTrue(mutation(['zyxwvutsrqponmlkjihgfedcba', 'qrstu']));

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

assert.isTrue(mutation(['Mary', 'Army']));

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

assert.isTrue(mutation(['Mary', 'Aarmy']));

mutation(["Alien", "line"]) should return true.

assert.isTrue(mutation(['Alien', 'line']));

mutation(["floor", "for"]) should return true.

assert.isTrue(mutation(['floor', 'for']));

mutation(["hello", "neo"]) should return false.

assert.isFalse(mutation(['hello', 'neo']));

mutation(["voodoo", "no"]) should return false.

assert.isFalse(mutation(['voodoo', 'no']));

mutation(["ate", "date"]) should return false.

assert.isFalse(mutation(['ate', 'date']));

mutation(["Tiger", "Zebra"]) should return false.

assert.isFalse(mutation(['Tiger', 'Zebra']));

mutation(["Noel", "Ole"]) should return true.

assert.isTrue(mutation(['Noel', 'Ole']));

--seed--

--seed-contents--

function mutation(arr) {
  return arr;
}

mutation(['hello', 'hey']);

--solutions--

function mutation(arr) {
  let hash = Object.create(null);

  arr[0]
    .toLowerCase()
    .split('')
    .forEach(c => (hash[c] = true));

  return !arr[1]
    .toLowerCase()
    .split('')
    .filter(c => !hash[c]).length;
}

mutation(['hello', 'hey']);