+ 1

Hey how do you use prompt info later in the code? JS

This is my code: function p(){ prompt("What is your name?"); } p(); var name = p(); document.write(name); How would I implement this correctly?

2nd Jun 2022, 8:10 PM
Ava Alford
2 Answers
+ 4
function p(){ let name = prompt("What is your name?"); return name; } //p(); var name = p(); document.write( name );
2nd Jun 2022, 8:19 PM
Jayakrishna 🇼🇳
+ 2
Jayakrishna🇼🇳 oh return! That makes sense. Thank you so much!
2nd Jun 2022, 8:30 PM
Ava Alford