I was wondering if there was a way to make the const change with an automated function (recursive) ?
I would want to find a recursive way to make it happen.
I thought of the following : (sorry for the const names, i can correct it if possible).
function fillArray() {
const d = [1, 2, 3];
d.fill(1, 2);
console.log(d);
return d;
}
fillArray();
I just discovered this property (fill), which is not going well.
**Your code so far**
const s = [5, 7, 2];
function editInPlace() {
// Only change code below this line
s[0] = 2;
s[1] = 5;
s[2] = 7;
// Using s = [2, 5, 7] would be invalid
// 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/105.0.0.0 Safari/537.36
Challenge: ES6 - Mutate an Array Declared with const
A const declaration for a variable holding an array means that you will use the same array thoughout the life of that variable, but you are free to change the contents of that array however you like.