Files
Nicholas Carrigan (he/him) 7117919d36 chore(learn): audit javascript algorithms and data structures (#41092)
* chore(learn): audit basic algorithm scripting

* chore(learn): audit basic data structures

* chore(learn): audit basic javascript

* chore(learn): audit debugging

* chore(learn): audit es6

* chore(learn): audit functional programming

* chore(learn): audit intermidate algorithms

* chore(learn): audit js projects

* chore(learn): audit object oriented programming

* chore(learn): audit regex

* fix(learn): remove stray .

* fix(learn): string to code

* fix(learn): missed some

* fix(learn): clarify strings

Based on Randy's feedback, clarifies string instances where quotes
were removed in favour of back ticks.

* fix: apply suggestions - thanks Randy! :)

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* fix: non-suggestion comments

* chore(learn): remove comments from codes

Removes the comments from the description and instruction code
blocks to ensure that all relevant information is translatable.

* fix: Apply suggestions from code review

Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com>

* fix: revert crowdin fix

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations.md

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* fix: Apply suggestions from code review

Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com>

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md

Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com>

* fix: Apply suggestions from code review

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com>

* chore: change voice

* fix: Christopher Nolan

* fix: expressions would evaluate

* fix: will -> would

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* fix: to work to push

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops.md

Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com>

* Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com>
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2021-03-02 17:12:12 -07:00

2.3 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
af2170cad53daa0770fabdea Mutations 5 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(mutation(['hello', 'hey']) === false);

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

assert(mutation(['hello', 'Hello']) === true);

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

assert(mutation(['zyxwvutsrqponmlkjihgfedcba', 'qrstu']) === true);

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

assert(mutation(['Mary', 'Army']) === true);

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

assert(mutation(['Mary', 'Aarmy']) === true);

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

assert(mutation(['Alien', 'line']) === true);

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

assert(mutation(['floor', 'for']) === true);

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

assert(mutation(['hello', 'neo']) === false);

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

assert(mutation(['voodoo', 'no']) === false);

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

assert(mutation(['ate', 'date']) === false);

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

assert(mutation(['Tiger', 'Zebra']) === false);

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

assert(mutation(['Noel', 'Ole']) === true);

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