There is another solution

I was solving ES6: Mutate an Array Declared with const on
The instruction told to use

s[0] = 2;

but I tested like this


and the test pasted. Than I looked the solution by camperbot but it isn’t same!
Not a problem but another solution found because of my curiosity :smile:
Want to know is that okay or something wrong with freecodecamp’s JS editor!

it’s not something expected, but it’s not wrong per se - it passes because the wanted output is the array with the elements in order
you are just not using the specific method mentioned

Change the array to [2, 5, 7] using various element assignments.

which can be considered wrong - note that in most challenges doing that would result in a failure

sort mutates the array in place, so it is a good example of mutating an array even if declared with const

note, if you would have done s = s.sort() that would have not been allowed

1 Like

Thank you @ieahleen for explainning mor about const !