Javascript switch case with Input Characters

 <!DOCTYPE html>

<html>

<body>

<script>  

grade=prompt("Enter your letter grade ");

var result;  

switch(grade){  

case 'A':

case 'a':

result=" 99-100 Excellent";  

break;  

case 'B':

case 'b':

result="95-98 Very Good ";  

break;  

case 'C':

case 'c':

result="88-94 Good ";  

break; 

case 'D':

case 'd':

result=" 75-87 Needs Improvement ";  

break; 

case 'E':

case 'e':

 result="74 below Failed  ";  

break; 

default:  

result="Invalid Grade ";  

}  

document.write(result);  

</script>  

</body>

</html>

Sample OUtput : 







Comments

Popular posts from this blog

Javascript Code using getElementById and If Else Statement

Window Screen Properties