(6/10)

Smarter Arrays — JavaScript typing lesson

Use array methods like map, filter, and reduce efficiently.

What you'll practice

Let's learn some JavaScript superpowers for arrays: `map()` and `filter()`! They're smart ways to create new arrays.

  • `.map()` creates a new array by doing something to each item in the original array.
  • `.filter()` creates a new array with only the items that pass a test.

Pro Access Required

This is a premium lesson. Upgrade to Pro to unlock this interactive exercise and continue your learning journey.

📜JavaScript

Smarter Arrays

0 WPM
0% Accuracy
0:00 Time elapsed
1
2
3
4
5
6
7
8
let numbers = [1, 2, 3, 4, 5];↵
↵
let squared_numbers = numbers.map(num => num * num);↵
let even_numbers = numbers.filter(num => num % 2 == 0);↵
↵
console.log(numbers);↵
console.log(squared_numbers);↵
console.log(even_numbers);
0 / 220
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
L
;:
'"
↵
⇧
Z
X
C
V
B
N
M
,<
.>
/?
⇧
Thumb
Index
Middle
Ring
Pinky