Bug on Manipulate arrays with .shift()?

Bug on Manipulate arrays with .shift()?
0.0 0

#1

here is my code:


  // 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();

this does not return as expected, instead throwing an error “assignment to undeclared variable removedFromOurArray” this has me absolutely stumped and i cant seem to find a suitable workaround, so any help is appreciated.


#2

figured it out, simply add var to the second line, just before “removedFromOurArray”.
so the line will read “var removedFromOurArray = ourArray.shift();”

this is a bit of an oversight from the developers that may confuse newcomers who are following the specific instructions to “only change code below this line”.


#3

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


#4

Thank you for posting this, I was really stumped on this challenge as well.


#5

Good eye @Aidanh15 !

I submitted a bug fix. I think I did that the right way. We’ll see.