Link Search Menu Expand Document

Mutate an Array Declared with const

Summary

  • Objects inside a const variable are still mutable.

Final Code

const s = [5, 7, 2];
function editInPlace() {
  // Only change code below this line
  s[0] = 2;
  s[1] = 5;
  s[2] = 7;
  // Only change code above this line
}
editInPlace();