+ 1
why this code isn’t working?
function main() { var themeNumber = parseInt(readLine(), 10) /* 1 - Light 2 - Dark 3 - Nocturne 4 - Terminal 5 - Indigo */ // введите код сюда 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; } }
7 Respuestas
+ 4
The key learning opportunity is how to read Error Message.
Let me emphasize the logic again.
You have five console.log
If the problem is with console.log
Then the error should be at first console.log
But now it shows fourth console.log,
so we check the line before.
When you program, you will meet a lot of bug. It is normal. Skill is to read error message and debug it.
+ 4
Missing colon after case(4) at line 23
Hint is error message
Error at Line 24, which is console.log("Terminal"),
so look into end of line 23
0
i fixed that, and it still dont work. It says that i have Syntax error
0
ou, nevermind, i guess Sololearn just lag and after i reboot it worked
0
yea, i was learning python all this time so i need a time to get used to JS :)
Thank you very much
0
Terminate the console.log with ;
0
Raphael Kuayi Indeed console.log doesn't have to end with semi-colon, because JavaScript has ASI (Automatic Semi-colon Insertion).
Semi-colon is usually optional, except for these keywords:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#automatic_semicolon_insertion