+ 1

How do i count variable in javascript

var G = 123456789; So how am i to count the variable G in javascript.

25th Sep 2022, 11:25 PM
Cindy K Hink
Cindy K Hink - avatar
5 Respostas
+ 3
console.log( String(G).length );
25th Sep 2022, 11:50 PM
SoloProg
SoloProg - avatar
+ 2
Thanks
26th Sep 2022, 12:04 AM
Cindy K Hink
Cindy K Hink - avatar
+ 2
String(G.length)
27th Sep 2022, 4:55 PM
Alex
Alex - avatar
+ 1
For numbers you need to implement logics for string you can use . length
26th Sep 2022, 1:27 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
U use the function of string(g).length to get the desired result
27th Sep 2022, 5:18 PM
faheem amjad
faheem amjad - avatar