Oliver Eyton-Williams bd68b70f3d
Feat: hide blocks not challenges (#39504)
* fix: remove isHidden flag from frontmatter

* fix: add isUpcomingChange

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>

* feat: hide blocks not challenges

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>
2020-09-03 15:07:40 -07:00

2.8 KiB

id, title, isRequired, challengeType, forumTopicId
id title isRequired challengeType forumTopicId
af2170cad53daa0770fabdea Mutations true 5 16025

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".

Instructions

Tests

tests:
  - text: <code>mutation(["hello", "hey"])</code> should return false.
    testString: assert(mutation(["hello", "hey"]) === false);
  - text: <code>mutation(["hello", "Hello"])</code> should return true.
    testString: assert(mutation(["hello", "Hello"]) === true);
  - text: <code>mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])</code> should return true.
    testString: assert(mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]) === true);
  - text: <code>mutation(["Mary", "Army"])</code> should return true.
    testString: assert(mutation(["Mary", "Army"]) === true);
  - text: <code>mutation(["Mary", "Aarmy"])</code> should return true.
    testString: assert(mutation(["Mary", "Aarmy"]) === true);
  - text: <code>mutation(["Alien", "line"])</code> should return true.
    testString: assert(mutation(["Alien", "line"]) === true);
  - text: <code>mutation(["floor", "for"])</code> should return true.
    testString: assert(mutation(["floor", "for"]) === true);
  - text: <code>mutation(["hello", "neo"])</code> should return false.
    testString: assert(mutation(["hello", "neo"]) === false);
  - text: <code>mutation(["voodoo", "no"])</code> should return false.
    testString: assert(mutation(["voodoo", "no"]) === false);
  - text: <code>mutation(["ate", "date"]</code> should return false.
    testString: assert(mutation(["ate", "date"]) === false);
  - text: <code>mutation(["Tiger", "Zebra"])</code> should return false.
    testString: assert(mutation(["Tiger", "Zebra"]) === false);
  - text: <code>mutation(["Noel", "Ole"])</code> should return true.
    testString: assert(mutation(["Noel", "Ole"]) === true);

Challenge Seed

function mutation(arr) {
  return arr;
}

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

Solution

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"]);