2018-10-04 14:37:37 +01:00
---
id: af2170cad53daa0770fabdea
title: Mutations
isRequired: true
challengeType: 5
2019-07-31 11:32:23 -07:00
forumTopicId: 16025
2018-10-04 14:37:37 +01:00
---
## Description
< section id = '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, < code > ["hello", "Hello"]< / code > , should return true because all of the letters in the second string are present in the first, ignoring case.
The arguments < code > ["hello", "hey"]< / code > should return false because the string "hello" does not contain a "y".
Lastly, < code > ["Alien", "line"]< / code > , should return true because all of the letters in "line" are present in "Alien".
Remember to use < a href = "http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target = "_blank" > Read-Search-Ask< / a > if you get stuck. Write your own code.
< / section >
## Instructions
< section id = 'instructions' >
< / section >
## Tests
< section id = 'tests' >
```yml
tests:
2018-10-20 21:02:47 +03:00
- text: < code > mutation(["hello", "hey"])</ code > should return false.
2019-07-24 01:47:32 -07:00
testString: assert(mutation(["hello", "hey"]) === false);
2018-10-20 21:02:47 +03:00
- text: < code > mutation(["hello", "Hello"])</ code > should return true.
2019-07-24 01:47:32 -07:00
testString: assert(mutation(["hello", "Hello"]) === true);
2018-10-20 21:02:47 +03:00
- text: < code > mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])</ code > should return true.
2019-07-24 01:47:32 -07:00
testString: assert(mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]) === true);
2018-10-20 21:02:47 +03:00
- text: < code > mutation(["Mary", "Army"])</ code > should return true.
2019-07-24 01:47:32 -07:00
testString: assert(mutation(["Mary", "Army"]) === true);
2018-10-20 21:02:47 +03:00
- text: < code > mutation(["Mary", "Aarmy"])</ code > should return true.
2019-07-24 01:47:32 -07:00
testString: assert(mutation(["Mary", "Aarmy"]) === true);
2018-10-20 21:02:47 +03:00
- text: < code > mutation(["Alien", "line"])</ code > should return true.
2019-07-24 01:47:32 -07:00
testString: assert(mutation(["Alien", "line"]) === true);
2018-10-20 21:02:47 +03:00
- text: < code > mutation(["floor", "for"])</ code > should return true.
2019-07-24 01:47:32 -07:00
testString: assert(mutation(["floor", "for"]) === true);
2018-10-20 21:02:47 +03:00
- text: < code > mutation(["hello", "neo"])</ code > should return false.
2019-07-24 01:47:32 -07:00
testString: assert(mutation(["hello", "neo"]) === false);
2018-10-20 21:02:47 +03:00
- text: < code > mutation(["voodoo", "no"])</ code > should return false.
2019-07-24 01:47:32 -07:00
testString: assert(mutation(["voodoo", "no"]) === false);
2019-09-30 13:33:57 -07:00
- text: < code > mutation(["ate", "date"] should return false</ 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);
2018-10-04 14:37:37 +01:00
```
< / section >
## Challenge Seed
< section id = 'challengeSeed' >
< div id = 'js-seed' >
```js
function mutation(arr) {
return arr;
}
mutation(["hello", "hey"]);
```
< / div >
< / section >
## Solution
< section id = 'solution' >
```js
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"]);
```
< / section >