0

what is wrong with my code?

var h = prompt("please enter your age"); switch (h){ case 1: alert("you are lying") break; case 2: alert("you are lying") break; case 3: alert("you are lying") break; case 4: alert("you are lying") break; I didn't put the full code, but i feel that the problem is in the beginning

15th Jun 2017, 7:02 PM
nicholas
nicholas - avatar
6 Answers
+ 6
@Limitless Really u have limitless knowledge of explaining things in easy way & limitless power of debugging 😁
15th Jun 2017, 8:09 PM
Sri Lakshmi
Sri Lakshmi - avatar
+ 3
var h = Number (prompt("please enter your age")); switch (h){ case 1: alert("you are lying") break; case 2: alert("you are lying") break; case 3: alert("you are lying") break; case 4: alert("you are lying") break; : :
16th Jun 2017, 1:20 AM
CalviŐ˛
CalviŐ˛ - avatar
+ 1
You need to add a parseInt(h) to make your switch go through an integer instead of a string. Here's my solution: https://code.sololearn.com/WW0fFXBzPIpz/?ref=app
15th Jun 2017, 7:08 PM
Limitless
Limitless - avatar
+ 1
Thanks man, it works wonders
15th Jun 2017, 7:14 PM
nicholas
nicholas - avatar
+ 1
😋
15th Jun 2017, 8:12 PM
Limitless
Limitless - avatar
0
cool, glad I could help
15th Jun 2017, 7:14 PM
Limitless
Limitless - avatar