Cannot understand the following line in question

I am on the following link and here it says

const s = [5, 6, 7];
s = [1, 2, 3];
s[2] = 45;
console.log(s);

s = [1, 2, 3] will result in an error. The console.log will display the value [5, 6, 45].

when I ran the code in the console

const s = [5, 6, 7];
s = [1, 2, 3];
s[2] = 45;
console.log(s);

I got an error

VM182:2 Uncaught TypeError: Assignment to constant variable.
at :2:3
I am very much confused why the question says “s = [1, 2, 3] will result in an error. The console.log will display the value [5, 6, 45].” because it gives me an error

Thanks. shouldn’t it be like following the question

I agree with the OP. It is unclear, to some extent, that you have to comment out the line.

This is the original

s = [1, 2, 3] will result in an error. The console.log will display the value [5, 6, 45].

I’d use:

s = [1, 2, 3] will result in an error. After commenting out that line, the console.log will display the value [5, 6, 45].

Alright, I will, thanks.

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