0 votes
in JavaScript by
Which of the following is the correct output for the following JavaScript code:

var grade='D';  

var result;  

switch(grade)  

{  

case'A':  

        result+="10";  

case'B':  

        result+=" 9";  

case'C':  

        result+=" 8";  

case 'D'  

result+=" 6";  

default:  

        result+=" 0";  

}  

document.write(result);  

a) 10

b) 6

c) 33

d) 0

1 Answer

0 votes
by

Answer: B

Reason: If we look at the given code carefully, we can see that here the "break" statement is not used after any of the case labels. Which means all the cases following "A" get executes if the following program is executed.

...