BETA freeCodeCamp -ES6: Mutate an Array Declared with const- possible bug report

BETA freeCodeCamp -ES6: Mutate an Array Declared with const- possible bug report
0

#1

Hello, my code:


"use strict";

const s = [5, 7, 2];
// change code below this line
s[0] = 2;
s[1] = 5;
s[2] = 7;
// change code above this line
console.log(s);

Result:
Do not replace const keyword. WRONG
s is declared with const. WRONG
Do not change the original array declaration. WRONG
s should be equal to [2, 5, 7]. GOOD

I don’t think my response is wrong.

Have a good day


#2

There’s an issue with the challenges that use the const keyword.


#3

Ok thanks you. So exercice with const won’t work.


#5

Seems to be working now. You and I have the same code and it works. Did you remember to add the editInPlace(); at the bottom of your code? Seem like you’re missing this part.

function editInPlace() {
  "use strict";
  // change code below this line
    s[0] = 2;
    s[1] = 5;
    s[2] = 7; 
    console.log(s);
  // change code above this line
}
editInPlace();```

#6

The browser always seems to scroll away from the first line and that’s how I’ve been screwing up because I couldn’t see the variable being declared.


#7

This is my version:
// change code below this line

s.unshift(s.pop());

// s = [2, 5, 7]; <- this is invalid

// change code above this line