Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable should be defined as 'let' not 'const' because it is changing. #13716

Closed
Ethan-Arrowood opened this issue Mar 3, 2017 · 3 comments
Closed

Comments

@Ethan-Arrowood
Copy link
Member

Use the Spread Operator To Evaluate Arrays In-Place

https://beta.freecodecamp.com/en/challenges/es6/use-the-spread-operator-to-evaluate-arrays-inplace

Issue Description

The arr2 variable is defined as a const, but is supposed to be able to be redefined in the exercise.

Browser Information

  • Browser Name, Version: Google Chrome, Version 56.0.2924.87 (64-bit)
  • Operating System: OS X El Capitan 10.11.6
  • Mobile, Desktop, or Tablet: Desktop

Potential Solutions

There are 2 options to fix this challenge:

  1. Remove the // change code below this line and // change code above this line so that the user can add the solution ...arr1 directly into arr2 instantiation.
    Solution would be:
const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
const arr2 = [...arr1];
  1. Change the initial instantiation of arr2 to: let arr2 = [];
    Solution would be:
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.

@Greenheart
Copy link
Member

@Ethan-Arrowood Nice catch!

Actually, this is solvable as it is - but this is most likely the intended way... 😄

copy-contents-of-array

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

@systimotic systimotic added the beta label Mar 3, 2017
@Ethan-Arrowood
Copy link
Member Author

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.

@raisedadead
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants