Mutate an Array Declared with const https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const

Tell us what’s happening:
what is the problem with my code?

Your code so far


const s = [5, 7, 2];
function editInPlace() {
  "use strict";
  // change code below this line
  s.unshift(2);
  s.pop() 
  // s = [2, 5, 7]; <- this is invalid
  
  // change code above this line
  return s;
}
editInPlace();

console.log(editInPlace())

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const

you’re executing editInPlace() twice, if you wan’t to see the output just log s.

1 Like

Thanks:fu::grinning: