Describe your problem and how to reproduce it:
In the challenge that I mentioned in the title there is an issue. Even when the output doesn't match with the challenge requirements but it still passes the challenge. I have linked some gifs so it is more understandable.
Add a Link to the page with the problem:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place
Tell us about your browser and operating system:
If possible, add a screenshot here (you can drag and drop, png, jpg, gif, etc. in this box):
The output doesn't match with the requirements but it still passes the challenge:
https://gyazo.com/f27f86327cd9dc9d5959c2dc456f1041
While this is the correct code and output:
https://gyazo.com/0d11507fed0226112f059f45c0e5b97f
This also passes the challenge:
https://gyazo.com/2e3ae5310e4b638b0156ffc174b2e155
Good catch!
The first test on this page uses:
assert(arr2.every((v, i) => v === arr1[i]));
A fun quirk with .every()
that I ran in to yesterday is that it returns true on an empty array. This error could likely be fixed by adding an assertion for arr2.length
.
Good catch!
The first test on this page uses:
assert(arr2.every((v, i) => v === arr1[i]));
A fun quirk with
.every()
that I ran in to yesterday is that it _returns true_ on an empty array. This error could likely be fixed by adding an assertion forarr2.length
.
Honestly I didn't know why it passed the challenge. Thank you for the explanation.
Opening this up for contributions. As @nhcarrigan mentions, we just need an additional condition in the assert
to test that arr2.length
is non-zero (which means it would be truthy).
you can find in stackovervlow
Most helpful comment
Good catch!
The first test on this page uses:
A fun quirk with
.every()
that I ran in to yesterday is that it returns true on an empty array. This error could likely be fixed by adding an assertion forarr2.length
.