+ 3
TheĀ„AIRWeb
try this:
alert("Designed by Air Philippines");
var user = prompt("Name");
confirm(user);
var passed = false
var email = prompt("Email");
while(passed===false){
if (email!=null && email.includes("@")){
passed = true
confirm(email);
alert("Thanks!");
}
else if(email===null){
break
}
else{
email = prompt("Invalid. Please include @ ")
}
}
console.log(.......)
+ 3
TheĀ„AIRWeb
how about this?
alert("Designed by Air Philippines");
var user = prompt("Name");
confirm(user);
var passed = false
while(passed===false){
var email = prompt("Email");
if (email.includes("@")){
passed = true
confirm(email);
alert("Thanks!");
}
else{
email = prompt("Invalid. Please include @ ")
}
}
console.log(.......)
+ 2
Window prompt()
https://www.w3schools.com/jsref/met_win_prompt.asp
Window confirm()
https://www.w3schools.com/jsref/met_win_confirm.asp
+ 1
You can't use else if without if.
+ 1
var user = prompt("Name");
if (user == null) {
alert("Please enter your name");
}
+ 1
the error occurs when you click the cancel button, which returns null and assigns null to email.
0
TheĀ„AIRWeb your code doesn't have an if statement. You can't use an else if statement without first using an if statement.
https://www.w3schools.com/js/js_if_else.asp
https://www.javascripttutorial.net/javascript-if-else-if/
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else
0
You don't need else... If
Just one condition and one counter condition so use if... else
0
Use if else ....
For better validation