Which of the following demonstrate the correct syntax for the switch statement?
A.
var myName= “Paul”
switch (myName){
case “Peter”
document.write(“My name is Peter.
“)
break
case “Paul”
document.write(“My name is Paul.
“)
break: (default);
document.write(“I do not have a name.
“)
}
B.
var myName= “Paul”
switch (myName){
case “Peter”
document.write(“My name is Peter.
“)
break
case “Paul”
document.write(“My name is Paul.
“)
break: (default);
document.write(“I do not have a name.
“)
}
C.
var myName= “Paul”
switch (myName){
case (Peter)
document.write(“My name is Peter.
“)
break
case (Paul)
document.write(“My name is Paul.
“)
break;
case: (default);
document.write(“I do not have a name.
“)
}
D.
var myName= “Paul”
switch (myName){
case (Peter)
document.write(“My name is Peter.
“)
break
case (Paul)
document.write(“My name is Paul.
“)
break;
case: (default);
document.write(“I do not have a name.
“)
}
Explanation: