+ 3

Can't Count Length of Variable in Javascript

You can see at line 21, I tried to use length property to the "result" variable but it results undefined. Please help me with this https://code.sololearn.com/WFvlUxU294Kr/?ref=app

7th Mar 2018, 4:01 PM
Keanu Taufan
Keanu Taufan - avatar
3 Answers
+ 6
There is also this method of converting it into string and then counts it's length. result = 17778 alert(result + "").length; Returns the length of result.
7th Mar 2018, 4:16 PM
Akash Pal
Akash Pal - avatar
+ 7
You can turn the variable result in string first and then can count it's length.Like this. result.toString().length. There are many other ways also to turn it into string.
7th Mar 2018, 4:09 PM
Akash Pal
Akash Pal - avatar
+ 2
Thanks for your help. It worked perfectly👌
7th Mar 2018, 4:20 PM
Keanu Taufan
Keanu Taufan - avatar