Basic JavaScript - Manipulate Arrays With shift Method

Tell us what’s happening:
I got the assignment right, I just don’t understand how it is possibly to change myArray since it is a constant… So when I did console.log(myArray) at the end, it displayed it without the shifted value. But a constant should be constant, i.e. unchangeable, right?

Your code so far

// Setup
const myArray = [["John", 23], ["dog", 3]];

// Only change code below this line
var removedFromMyArray = myArray.shift();

Your browser information:

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

Challenge: Basic JavaScript - Manipulate Arrays With shift Method

Link to the challenge:

You cannot reassign or redeclare variables when using const but the contents of objects/arrays can be modified.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.