Javascript if statement | Sololearn: Learn to code for FREE!
+ 2

Javascript if statement

var month = parseInt(readLine(), 10) if(month == "August") { console.log("vacation") } Where I am wrong here?

8th Sep 2021, 6:02 AM
Rabiya Tayyab
Rabiya Tayyab - avatar
9 Antworten
- 1
Hi ! I need your help, plleeeeaase I'm stuck on this code coach since two weeks. I tried a lot of things. This is my last code : var month = (readLine(), 10) //your code goes here if (month == "August") { console.log("vacation"); }
15th Sep 2021, 1:04 PM
Mickart
Mickart - avatar
+ 4
Emi_ICKART just write var month = readLine();
15th Sep 2021, 1:19 PM
A͢J
A͢J - avatar
8th Sep 2021, 6:50 AM
Rabiya Tayyab
Rabiya Tayyab - avatar
+ 3
It works! Thank you so much ! I had tried this but certainly modified something else at the same time ...
15th Sep 2021, 3:52 PM
Mickart
Mickart - avatar
+ 2
I dont think parseInt() will return a string.
8th Sep 2021, 6:23 AM
arturop-404
arturop-404 - avatar
+ 2
Rabiya Tayyab There is a problem to taking input. Don't parse with Int. That would be called as SL bug or intensely they have this.
8th Sep 2021, 6:47 AM
A͢J
A͢J - avatar
+ 1
readLine is not defined
8th Sep 2021, 6:21 AM
Saurabh
Saurabh - avatar
+ 1
Yes you are right. That's where I was doing a mistake. Thanks so much
8th Sep 2021, 6:39 AM
Rabiya Tayyab
Rabiya Tayyab - avatar
+ 1
Arturop yes parseInt returns integer value not String. readLine () bydefault accept everything as a String so to get integer you have parse the input with parseInt but in this practice input is String so no need to parse.
10th Sep 2021, 3:19 AM
A͢J
A͢J - avatar