Java Script


JavaScript Tutorial


Admission Enquiry Form


Print a message "win or lose " when score is assigned to a variable using if else statement.

Example:

<html>
<head>
<title>win or lose according to score using if else</title>
</head>

<body>
<script>
var score;
score=110;

if(score>=100)
{
document.write("we will win the match!!");
}
else
{
document.write("we will lose the match!!");
}
</script>
</body>
</html>



Print a message "win or lose " according to score entered in prompt() using if else.

Example:

<html>
<head>
<title>win or lose according to score using prompt() in if else</title>
</head>

<body>
<script>
var score;
score=parseInt(prompt("Enter score"));

if(score>=100)
{
document.write("we will win the match!!");
}
else
{
document.write("we will lose the match!!");
}
</script>
</body>
</html>

Print a message "win or lose " according to score entered on Button click using function

Example:

<html>
<head>
<title>win or lose according to score on Button click in if else using function</title>
<script>
function win_lose()
{
var score;
score=parseInt(prompt("Enter score"));

if(score>=100)
{
document.write("we will win the match!!");
}
else
{
document.write("we will lose the match!!");
}

}//end of function
</script>

</head>

<body>
<input type="button" value="click" onClick="win_lose()">
</body>
</html>