var ourArray = ["Stimpson", "J", ["cat"]];
ourArray.pop(); // ourArray now equals ["Stimpson", "J"]
ourArray.push(["happy", "joy"]); // ourArray now equals ["Stimpson", "J", ["happy", "joy"]]
var myArray = ["John", 23, ["cat", 2]];
myArray.pop();
// Only change code below this line.
*myArray.push(["dog", 3]);*
// Only change code above this line.
(function(z){return 'myArray = ' + JSON.stringify(z);})(myArray);
Asked
Active
Viewed 476 times
-1

Andreas
- 21,535
- 7
- 47
- 56

Cosimo Bressi
- 3
- 3
-
After removing the two `*` the code should work. So what exactly isn't working? Any errors in the console (-> F12)? – Andreas Nov 16 '15 at 15:02
-
`Array.prototype.push.apply( myArray, ["dog", 3])` – pawel Nov 16 '15 at 15:07
1 Answers
2
Array.push will push anything onto the array, what you are doing is pushing another array into the array, you will need to push "dog" and 3 without the array.
Array.push can take multiple arguments. So just do myArray.push("dog", 3);

Sean_A91
- 333
- 4
- 15
-
Why you think it should be `.push("dog"); .push(3)` instead of `.push(["dog", 3])`? The example already pushes an array with two entries onto `ourArray`. And `myArray` contains a similar entry: `["cat", 2]` – Andreas Nov 16 '15 at 15:00
-
Because that is how the question is worded. I saw the cat part, but that is not what they asked. Also there is nothing wrong with `myArray.push(["dog", 3])` so if they state it isn't doing what they expect, then that also co-insides with the question. – Sean_A91 Nov 16 '15 at 15:03