Tell us what’s happening:
any help i am stucking
Your code so far
const s = [5, 7, 2];
function editInPlace() {
"use strict";
// change code below this line
// s = [2, 5, 7]; <- this is invalid
// change code above this line
}
editInPlace();
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const/
to change the values of an array you must use square bracket notation.
For eg.
const arr = [‘hello’, ‘there’];
arr[0] = ‘goodbye’;
the last line will change ‘hello’ to ‘goodbye’
const s = [5, 7, 2];
function editInPlace() {
"use strict";
// change code below this line
let x = s.pop();
s.unshift(x);
// s = [2, 5, 7]; <- this is invalid
// change code above this line
}
editInPlace();
Hi ! I am not sure if you have posted to ask for help. If you do need help, click on the “ask for help” button on the relevant challenge so your post contains a link to the challenge and your code.