(8/10)

Asking Questions — JavaScript typing lesson

Use prompt and alert to interact with users.

What you'll practice

Let's make our program interactive! The `prompt()` command shows a pop-up box to ask the user a question.

  • `prompt()` shows a pop-up and waits for you to type something and click OK.
  • Whatever you type is stored in the variable (in this case, user_name).
📜JavaScript

Asking Questions

0 WPM
0% Accuracy
0:00 Time elapsed
1
2
3
let user_name = prompt('what is your name');↵
let greeting = 'hello ' + user_name;↵
console.log(greeting);
0 / 104
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