Manipulate Arrays With shift()

Manipulate Arrays With shift()
0.0 0

#1

I entered the code below,but seems to be incorrect,can anyone show me the correct way?thanks

Your code so far


// Example
var ourArray = ["Stimpson", "J", ["cat"]];
removedFromOurArray = ourArray.shift();
// removedFromOurArray now equals "Stimpson" and ourArray now equals ["J", ["cat"]].

// Setup
var 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 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/manipulate-arrays-with-shift


#2

Seems to be a bug in the tests. If you add var in front of removedFromOurArray, it will formally declare it and pass tests.


#3

thank you for your reply. Problem solved:)


#4

var removedFromMyArray = myArray.shift();
and
removedFromMyArray = myArray.shift();

both don’t work for me, anyone got any suggestions? Is it still bugged?


#5

Not working for me either :frowning:


#6

Have you tried putting a var in front of removedFromOurArray?


#7

I did, but it won’t let me pass.

EDIT: read your post wrong. Tried it, and that works :slight_smile: That must be something to look at though, I was only looking at my code below the line.