+ 1

Please check if I get and write the switch statement right!

Switch statement is also a conditional statement like if and else if statement but in more reliable way. The structure:    switch (conditional variable) { case condition 1:      conditional code      break; case condition 2:      conditional code      break; case condition 3:      conditional code      break; default:      conditional code real code: var baby = "crying" switch (baby) {     case "sleeping":         alert ("Green light")         break;     case "playing":         alert ("Y

27th Oct 2016, 8:53 AM
Waqas Shah
Waqas Shah - avatar
1 Answer
+ 1
Code looks good. Just add ; at the end of variable and at the end of alerts.
27th Oct 2016, 10:14 AM
Nemanja Simović
Nemanja Simović - avatar