https://beta.freecodecamp.com/en/challenges/es6/use-the-spread-operator-to-evaluate-arrays-inplace
The arr2 variable is defined as a const, but is supposed to be able to be redefined in the exercise.
There are 2 options to fix this challenge:
// change code below this line
and // change code above this line
so that the user can add the solution ...arr1
directly into arr2
instantiation.const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
const arr2 = [...arr1];
arr2
to: let arr2 = [];
const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
let arr2 = [];
// change code below this line
arr2 = [...arr1];
// change code above this line
Both of these solutions currently pass the given tests. I want to clean up this exercise so its easier to understand for users.
@Ethan-Arrowood Nice catch!
Actually, this is solvable as it is - but this is most likely the intended way... :smile:
I suggest that we slightly change the format of the challengeSeed
to solve this:
const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
const arr2 = []; // Change this line.
arr1.push('JUN');
console.log(arr2); // arr2 should not be affected
And I think we should add the hint to use the .push() function. Or hint to using something from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array .
I'll go ahead and make this change this evening.
@Ethan-Arrowood we are removing MDN links in favor of having a hints feature for the challenges than simply pointing to a resource that users may find a bit daunting while learning.
Nevertheless thanks a lot for the issue, and your contributions.
Most helpful comment
@Ethan-Arrowood Nice catch!
Actually, this is solvable as it is - but this is most likely the intended way... :smile:
I suggest that we slightly change the format of the
challengeSeed
to solve this: