+ 1
Javascript switch statement
function main() { var themeNumber = parseInt(readLine(), 10); /* 1 - Light 2 - Dark 3 - Nocturne 4 - Terminal 5 - Indigo */ // Your code here switch(themeNumber) case 1: console.log("Light"); break; case 2: console.log("Dark"); break; case 3: console.log("Nocturne"); break; case 4: console.log("Terminal"); break; case 5: console.log("Indigo"); break; } Where is the error in the above program
4 Antworten
+ 2
I have seen with the brackets immediately so but still tested in SL Playground. And yes I knew it, that works. Happy coding!
+ 5
You need Brackets Rabiya Tayyab
switch(themeNumber){
…
}
+ 1
Yeah you have written everything omin one block after switch case you need to put bracket till end of your all cases . using default is also a good practice if your case will not work then default statement will execute