+ 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; } }

23rd Jul 2022, 9:46 AM
Lakarov
Lakarov - avatar
7 Answers
+ 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.
23rd Jul 2022, 10:09 AM
Gordon
Gordon - avatar
+ 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
23rd Jul 2022, 9:55 AM
Gordon
Gordon - avatar
0
i fixed that, and it still dont work. It says that i have Syntax error
23rd Jul 2022, 9:58 AM
Lakarov
Lakarov - avatar
0
ou, nevermind, i guess Sololearn just lag and after i reboot it worked
23rd Jul 2022, 10:00 AM
Lakarov
Lakarov - avatar
0
yea, i was learning python all this time so i need a time to get used to JS :) Thank you very much
23rd Jul 2022, 10:11 AM
Lakarov
Lakarov - avatar
0
Terminate the console.log with ;
24th Jul 2022, 9:32 PM
Kuayi Raphael
Kuayi Raphael - avatar
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
25th Jul 2022, 1:52 AM
Gordon
Gordon - avatar