Files
freecodecamp--freecodecamp/curriculum/challenges/english/blocks/basic-algorithm-scripting/af2170cad53daa0770fabdea.md
T
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

124 lines
2.3 KiB
Markdown

---
id: af2170cad53daa0770fabdea
title: Mutations
challengeType: 1
forumTopicId: 16025
dashedName: 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`.
```js
assert.isFalse(mutation(['hello', 'hey']));
```
`mutation(["hello", "Hello"])` should return `true`.
```js
assert.isTrue(mutation(['hello', 'Hello']));
```
`mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])` should return `true`.
```js
assert.isTrue(mutation(['zyxwvutsrqponmlkjihgfedcba', 'qrstu']));
```
`mutation(["Mary", "Army"])` should return `true`.
```js
assert.isTrue(mutation(['Mary', 'Army']));
```
`mutation(["Mary", "Aarmy"])` should return `true`.
```js
assert.isTrue(mutation(['Mary', 'Aarmy']));
```
`mutation(["Alien", "line"])` should return `true`.
```js
assert.isTrue(mutation(['Alien', 'line']));
```
`mutation(["floor", "for"])` should return `true`.
```js
assert.isTrue(mutation(['floor', 'for']));
```
`mutation(["hello", "neo"])` should return `false`.
```js
assert.isFalse(mutation(['hello', 'neo']));
```
`mutation(["voodoo", "no"])` should return `false`.
```js
assert.isFalse(mutation(['voodoo', 'no']));
```
`mutation(["ate", "date"])` should return `false`.
```js
assert.isFalse(mutation(['ate', 'date']));
```
`mutation(["Tiger", "Zebra"])` should return `false`.
```js
assert.isFalse(mutation(['Tiger', 'Zebra']));
```
`mutation(["Noel", "Ole"])` should return `true`.
```js
assert.isTrue(mutation(['Noel', 'Ole']));
```
# --seed--
## --seed-contents--
```js
function mutation(arr) {
return arr;
}
mutation(['hello', 'hey']);
```
# --solutions--
```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']);
```