0
Why my code doesn't work?
I really don't get it https://code.sololearn.com/Wc9HQiaxuT45/?ref=app
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("?")) .
+ 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...
0
You compare string with integer, write:
var day = +prompt("?");
or
switch (+day) {
or
case "1":
case "2":
case "3":