Tell us what’s happening:
Your code so far
// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.shift(); // ourArray now equals ["J", "cat"]
ourArray.unshift("Happy");
// ourArray now equals ["Happy", "J", "cat"]
// Setup
var myArray = [["John", 23], ["dog", 3]];
myArray.shift();
// Only change code below this line.
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
.
Link to the challenge:
https://www.freecodecamp.org/challenges/manipulate-arrays-with-unshift
Logiar
March 27, 2018, 7:04am
2
What are you having trouble with?
caseydev:
// Example
var ourArray = [“Stimpson”, “J”, “cat”];
ourArray.shift(); // ourArray now equals [“J”, “cat”]
ourArray.unshift(“Happy”);
// ourArray now equals [“Happy”, “J”, “cat”]
// Setup
var myArray = [[“John”, 23], [“dog”, 3]];
myArray.shift();
// Only change code below this line.
myArray should now have [[“Paul”, 35], [“dog”, 3]].
Logiar
March 27, 2018, 8:43am
4
So what have you tried to do so far?
Edit: After the shift in the setup the array is [[“dog”, 3]]
. unshift
acts similar to push
just that it adds an element to the start of the array rather than the end, so you need to unshift
something that makes the array into [[“Paul”, 35], [“dog”, 3]]