fix(curriculum): falsy bouncer - do not mutate the original array (#47718)

Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com>
This commit is contained in:
tanmay thakral
2022-10-01 13:27:53 -07:00
committed by GitHub
parent 59aa1a252d
commit 35b607d2d8

View File

@@ -8,7 +8,7 @@ dashedName: falsy-bouncer
# --description--
Remove all falsy values from an array.
Remove all falsy values from an array. Return a new array; do not mutate the original array.
Falsy values in JavaScript are `false`, `null`, `0`, `""`, `undefined`, and `NaN`.
@@ -40,6 +40,14 @@ assert.deepEqual(bouncer([false, null, 0, NaN, undefined, '']), []);
assert.deepEqual(bouncer([null, NaN, 1, 2, undefined]), [1, 2]);
```
You should not mutate `arr`.
```js
const arr = ['a', false, 0, 'Naomi'];
bouncer(arr);
assert.deepEqual(arr, ['a', false, 0, 'Naomi'])
```
# --seed--
## --seed-contents--