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

Create a Select Box , Add and Remove Value on a List Box

JAVASCRIPT code : Random Text Colors on Canvas , Random Button Colors using fillText, setfillStyle ,Math.random

Javascript Code : Random Display of Shapes with Different Colors using fillRect , clearRect, For Loop , Styling Buttons using Javascript