0

The switch Statement - JS practice - 17.2 Dark Theme task problem

whyyy my code does'nt work... :((( Problem: The user can choose the color theme for the browser: 1. Light 2. Dark 3. Nocturne 4. Terminal 5. Indigo You are given a program that takes the number as input. Complete the program so that it will output to the console the theme according to input number. Sample Input 2 Sample Output Dark MY CODE: function main() { var themeNumber = parseInt(readLine(), 10) switch (themeNumber) { case 1: document.write("Light"); break; case 2: document.write("Dark"); break; case 3: document.write("Nocturne"); break; case 4: document.write("Terminal"); break; case 5: document.write("Indigo"); break; }

27th Aug 2021, 11:50 AM
Pawel
11 odpowiedzi
+ 8
It's conSole.log() not conCole.log()
27th Aug 2021, 12:29 PM
Simba
Simba - avatar
+ 5
In Sololearn JavaScript code practices, you need to use console.log() to print the output. Also, you're missing `}` at the end.
27th Aug 2021, 12:21 PM
Simba
Simba - avatar
+ 2
OMG.... burning with shame... many thx again... Final output: function main() { var themeNumber = parseInt(readLine(), 10) 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; } }
27th Aug 2021, 12:35 PM
Pawel
+ 1
thx, I've changed to "console.log" and added '}' at the end... but this code still produce error... function main() { var themeNumber = parseInt(readLine(), 10) switch(themeNumber) { case 1: concole.log("Light"); break; case 2; concole.log("Dark"); break; case 3: concole.log("Nocturne"); break; case 4: concole.log("Terminal"); break; case 5: concole.log("Indigo"); break; } } OUTPUT ERROR: /usercode/file0.js:23 case 2; ^ SyntaxError: Unexpected token ';' at wrapSafe (internal/modules/cjs/loader.js:979:16) at Module._compile (internal/modules/cjs/loader.js:1027:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) at Module.load (internal/modules/cjs/loader.js:928:32) at Function.Module._load (internal/modules/cjs/loader.js:769:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47
27th Aug 2021, 12:28 PM
Pawel
0
desde hace dos días estoy en esta practica con este código ----> function main() { var themeNumber = parseInt(readLine(), 10) 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; } } console.log(main()); ¿entienden? ..... console.log(main()) solo por está linea, el Output era "undefined"; Dos días; buscando errores en mi código. Intenté con un editor de js, y si funciono PERO en sololearn NO ... pues en la practica no se coloca ... console.log(main()).
2nd Nov 2021, 5:19 PM
Maria Romani Herrera
Maria Romani Herrera - avatar
0
here is any problem with my code? 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; } }
20th May 2022, 1:16 AM
dipak
0
I had the same problem as you it helped me to delete the comments and then it worked
13th Jul 2022, 6:54 PM
Miroslav Janďourek
0
Can someone explain to me what’s wrong with this code function main() { var themeNumber = parseInt(readLine(), 10) switch (themeNumber){ case1: 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; } }
13th Nov 2022, 1:29 PM
Mourad Jaffali
0
Readline…33
13th Nov 2022, 10:46 PM
Andoni Hernández
Andoni Hernández - avatar
0
Finish
13th Nov 2022, 10:47 PM
Andoni Hernández
Andoni Hernández - avatar
0
function main() { var themeNumber = parseInt(readLine(), 33)
13th Nov 2022, 10:48 PM
Andoni Hernández
Andoni Hernández - avatar