If Else statements in JavaScript Example

In this post, we will discuss how to use if else statement in javascript. Also, you can check my previous posts  on:
Syntax of if else statement:
if (condition) {
else if (condition)  {
else if (condition)  {
Below is an example of if else statement:
<script language=”JavaScript” type=”text/javascript”>
        var age = eval(prompt(“How much you scored?”, “”));
        if (age >= 60) {
            alert(“First Division”);
        else if (age > 50 && age < 60) {
            alert(“Second Division”);
        else if (age >= 30 && age < 50) {
            alert(“Third Division”);
        else {
Here in this example, it will first prompt the user to enter a value and according to the condition, it will alert the message. See fig below:
Once you enter the value it will show alert box according to the condition like below:
Check out Best Alternative to InfoPath -> Try Now

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →