feat(learn): add tests to use a callback function in the sort method (#40847)

pull/41038/head
Ismail Tlemçani 2021-02-10 12:35:23 +01:00 committed by GitHub
parent 959fe8323a
commit 0f8449788c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -49,6 +49,20 @@ The function should return a new array, not the array passed to it.
assert(nonMutatingSort(globalArray) !== globalArray);
```
`nonMutatingSort([1, 30, 4, 21, 100000])` should return `[1, 4, 21, 30, 100000]`.
```js
assert(JSON.stringify(nonMutatingSort([1, 30, 4, 21, 100000])) ===
JSON.stringify([1, 4, 21, 30, 100000]))
```
`nonMutatingSort([140000, 104, 99])` should return `[99, 104, 140000]`.
```js
assert(JSON.stringify(nonMutatingSort([140000, 104, 99])) ===
JSON.stringify([99, 104, 140000]))
```
# --seed--
## --seed-contents--