0
Prompt (JavaScript) in "if"
Is it possible to put a prompt in, for instance, an "if" statement (or whatever they are called)? If so, how? What about a "function?"
3 Réponses
- 1
It definitely is possible! To put one in an if statement, you would just do the following:
if(statement){
x = prompt("Enter a number!");
}
This will only prompt the user if the statement is true.
The same can be done with functions:
function func(x){
x = prompt("Enter a number!");
return x;
}
var user;
document.write(func(user));
0
Thank you!
- 1
No problem! 👍😉