(6/10)
Adding To An Array — JavaScript typing lesson
Learn to add and modify items in JavaScript arrays.
What you'll practice
Let's add a new toy to our toy box! We can use the special command `.push()` to add items to the end of an array.
- `.push()` is a special command (a method) attached to the array variable.
- The item you want to add goes inside the parentheses.
📜JavaScript
Adding To An Array
0 WPM
0% Accuracy
0:00 Time elapsed
1
2
3
4
5
let toy_box = ['robot', 'car'];↵
console.log(toy_box);↵
toy_box.push('train');↵
console.log('i got a new toy');↵
console.log(toy_box);
0 / 130
Press This!
👇
`~
1!
2@
3#
4$
5%
6^
7&
8*
9(
0)
-_
=+
⌫
⇥
Q
W
E
R
T
Y
U
I
O
P
[{
]}
\|
⇪
A
S
D
F
G
H
J
K
;:
'"
↵
⇧
Z
X
C
V
B
N
M
,<
.>
/?
⇧
Thumb
Index
Middle
Ring
Pinky