JavaScript Program to Display Grade of a Student

Write a JavaScript program to display grade of a student. here we are using else-if ladder construct.



Source Code
<html>
<head>
    <title>Find grade of student</title>
</head>
<body>
<script type="text/javascript">
    var marks;
    marks = 78;
    if(marks >= 75)
    {
        document.write("You have got Distinction");
    }
    else if(marks >=60 )
    {
        document.write("You have got First Class");
    }
    else if(marks >=50 )
    {
        document.write("You have got Second Class");
    }
    else if(marks >=40 )
    {
        document.write("You are passed");
    }
    else
    {
        document.write("You are failed");
    }
</script>
</body>
</html>
Output





"Coding Hub - Learn to code" app now available on Google Play Store