we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "get the first number of the integer in js"
Orson
18 Nov 2017
1var number = 132943154134;
2
3// convert number to a string, then extract the first digit
4var one = String(number).charAt(0);
5
6// convert the first digit back to an integer
7var one_as_number = Number(one); 
8