0

Why my code doesn't work?

I really don't get it https://code.sololearn.com/Wc9HQiaxuT45/?ref=app

28th Jan 2019, 1:08 AM
Raphael von Alchemy
Raphael von Alchemy - avatar
3 Answers
+ 4
prompt() creates a string. Your case conditions are numbers. They are not entirely equal. So, change it to "1", "2", "3" with quotes OR wrap the input like this Number(prompt("?")) .
28th Jan 2019, 1:12 AM
James
James - avatar
+ 4
Raphael von Alchemy Just adding to the correct information James has already given you, with more alternative to converting a string to a number Or (parseInt(day)) parseInt("1") convert string to number Or (+day) unary operator (+"1") convert string to number The more options you have...
28th Jan 2019, 2:21 AM
ODLNT
ODLNT - avatar
0
You compare string with integer, write: var day = +prompt("?"); or switch (+day) { or case "1": case "2": case "3":
28th Jan 2019, 5:06 AM
Š˜Š³Š¾Ń€ŃŒ ŠÆŠŗŠ¾Š²ŠµŠ½ŠŗŠ¾
Š˜Š³Š¾Ń€ŃŒ ŠÆŠŗŠ¾Š²ŠµŠ½ŠŗŠ¾ - avatar