Tell us what’s happening:
Hi,
I have a question about modifying the array. Since we have numbered saved in a array 2, 5, 7, why we can’t use those numbers/indexes to assign new array?
Why is the only way to assign in this way:
const s = [5, 7, 2];
function editInPlace() {
“use strict”;
s[0] = 2;
s[1] = 5;
s[2] = 7;
}
editInPlace();
Your code so far
const s = [5, 7, 2];
function editInPlace() {
'use strict';
// Only change code below this line
// Using s = [2, 5, 7] would be invalid
s[0] = s[2];
s[1] = s[0];
s[2] = s[1];
// Only change code above this line
}
editInPlace();
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
.
Challenge: Mutate an Array Declared with const
Link to the challenge: