+ 2

Name Input

How do I make an Alert with Input, followed by an Alert that uses the Input in Web. For example: Whats your name? <Input> OK, <Input>, lets play! Can somebody help me (I am a beginner)

13th Jun 2019, 3:34 PM
Macholilo
6 Answers
+ 5
When you don't need the name elsewhere: JS: alert("OK, " + prompt("Whats your name?") + ", lets play!"); ES6: alert(`OK, ${prompt("Whats your name?"}, lets play!`); If you DO need it later: JS: var name = prompt("Whats your name?"); alert("OK, " + name + ", lets play!"); ES6: const name = prompt("Whats your name?"); alert(`OK, ${name}, lets play!`);
13th Jun 2019, 3:38 PM
Airree
Airree - avatar
+ 1
Thx!
13th Jun 2019, 3:48 PM
Macholilo
+ 1
Oh thank you!
13th Jun 2019, 4:01 PM
Macholilo
+ 1
And how do I get this into a specific Line?
13th Jun 2019, 4:04 PM
Macholilo
0
So when I put this into my code, its in the end, but how do I get it for example in the 3rd line?
13th Jun 2019, 4:11 PM
Macholilo