ES6 - Mutate an Array Declared with const

Tell us what’s happening:

Describe your issue in detail here.

I would like to know hot to go about solving this problem in ES6. I tried other methods and I’m here

Your code so far

const s = [5, 7, 2];
function editInPlace() {
  // Only change code below this line

 s = [2, 5, 7]
 s[0] = 2;
 s[1] = 5;
 a[2] = 7;
 console.log(s);
  // Only change code above this line
}
editInPlace();

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36

Challenge Information:

ES6 - Mutate an Array Declared with const

It says that this is invalid.
Just switch your a to the letter s.

2 Likes

I don’t think you read my code. The only error I get is " s should be equal to [2, 5, 7] ."

I’m using an “s” as required NOT a. If I use “a” it says undefined

Using s = [2, 5, 7]; is invalid, the instructions clearly say. You shouldn’t use it. Variables declared using the const keyword cannot be re-assigned but can mutate.

Then replace the a with an s. Just as @anon86258595 suggested.

3 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.