Push( ) to myArray

Push( ) to myArray
0

#1
myArray.push(["dog",31]);
where is wrong?

#2

could you add your codepen here


#3

I don’t see anything wrong there. That should push that two item array onto your array myArr.

Can we see the code? What is happening that you think shouldn’t?


#4
// Only change code below this line.
var myArray = [["John",23],["cat",2]];
myArray.push(["dog",31]);
// ourArray now equals [["John",23],["cat",2],["dog",31]]

#5

I just cant find out where is wrong

var myArray = [["John",23],["cat",2]];
myArray.push(["dog",31]);
// ourArray now equals [["John",23],["cat",2],["dog",31]]

#6

That code works just fine for me. See this pen. (press ctrl-shft-j to open the console.)

The only problem is the curly (smart) quotes but that may be a result of the cut/paste and the forum.

And the variable ourArray? That is part of the example. I’m not sure why that comment is at the end. But I would reset the challenge (“reset your code” on the left) and reenter your line:

myArray.push(["dog", 3]);

on line 9. It works for me. Check back with us if that doesn’t solve your problem.


#7

It is the inverted commas.
writing with your hand is much better than copying.
As Kevin said it is a copying problem


#8

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.


#9

OP’s posts were written with straight quotation marks, not curly ones, so that’s probably not the issue.

@sandy1: have you checked if your variable name matches the one the challenge requires? Is it testing myArray or ourArray?


#10

I make mistake 3 to 31,thank you guys!