What will be the output of the following JavaScript code?
var grade=’A’;
var result;
switch(grade)
{
case ‘A’:
result+=”10″;
case ‘B’:
result+=” 9″;
case ‘C’:
result+=” 8″;
default:
result+=” 0″;
}
document.write(result);
a) 10
b) 27
c) 8
d) 0
Answer: b
Explanation: The above code does not have a break statement after the cases in the switch loop. Therefore all of the cases following “A” will get executed.
Related Posts
The basic purpose of the toLocaleString() is to _________
Identify the process done in the following JavaScript code snippet?
o = {x:1, y:{z:[false,null,””]}};
s = JSON.stringify(o);
p = JSON.parse(s);The purpose of extensible attribute is to __________
What is the prototype represents in the following JavaScript code snippet?
function f() {};To determine whether one object is the prototype of (or is part of the prototype chain of) another object, one should use the ____________
In the following syntax, the data type within the square brackets must be ___________
book[datatype]=assignment_value;A linkage of series of prototype objects is called as ________
Join The Discussion