+ 2

What is wrong with this code?

Var day= prompt("Please Enter a number:", 1); Switch(day) { Case 1: Document.write("Monday"); Break; //other cases Default: Document.write("Another Day") ; } //It always does the default case instead of taking my input

20th Mar 2018, 5:53 PM
Alex
Alex - avatar
2 Answers
+ 4
Remove those uppercase letters javascript is case sensitive prompt() returns a string so you need to change the input to integer. var day= parseInt(prompt("Please Enter a number:", 1));
20th Mar 2018, 6:01 PM
Toni Isotalo
Toni Isotalo - avatar
- 1
what is ur input?! the "Please....." or 1 ? u see where I'm going with?
20th Mar 2018, 5:57 PM
Farshaad Heydari
Farshaad Heydari - avatar