In my
previous post, I explained about if statement, if-else statement. In addition
to these, Javascript provides if-else if- else ladder, used to choose a
solution, when you had multiple alternatives.
Syntax
if(condition){
//Block of statements
}else
if(condition){
//Block of statements
}else{
//Block of statements
}
ladder.html
<!DOCTYPE html> <html> <head> <title>if-else if-else statement</title> </head> <body> <script type="text/javascript"> var marks = prompt("Enter Your marks", 100); if (marks < 35) { document.write("You are failed"); } else if (marks < 50) { document.write("You are passed and got third class"); } else if (marks < 60) { document.write("You are passed and got second class"); } else if (marks < 70) { document.write("You are passed and got first class"); } else { document.write("You are passed and got distinction"); } </script> </body> </html>
No comments:
Post a Comment