freeCodeCamp / curriculum

The freeCodeCamp curriculum and lesson editor
Creative Commons Attribution Share Alike 4.0 International
81 stars 124 forks source link

Destructuring with the Rest Operator , assertion accepts an empty array #281

Closed parent-tobias closed 5 years ago

parent-tobias commented 6 years ago

Describe the bug

In the assignment ES6: Use Destructuring Assignment with the Rest Operator to Reassign Array Elements, if an empty array is returned, the assignment is passed.

To Reproduce

Steps to reproduce the behavior:

  1. Go to 'https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements/'
  2. Return an empty array from the function
  3. Run tests
  4. See error

Expected behavior

The returned array should be the length of the passed array, less two. The assertion assert(arr.every((v, i) => v === i + 3)); returns true because it is an empty array, thus passing an incorrect response.

Desktop (please complete the following information):

ojeytonwilliams commented 5 years ago

I've taken a look at this and it does need a bit of work. Should have a PR soon.