0

I have the value 56.024096385542165 and I want the number before the dot. (In this case, it's 56).

How can I do this using JavaScript?

Tim Cooper
  • 151,519
  • 37
  • 317
  • 271
Hugo M.
  • 1,223
  • 3
  • 19
  • 30

1 Answers1

7

Just do

parseInt(yournumber, 10)

PSL
  • 122,084
  • 19
  • 250
  • 241
  • Do not forget, that `parseInt()` requires first parameter to be string. If you are using linters, there will be a warning. So better way is `parseInt(String(yournumber), 10)`. – B. Bohdan Dec 03 '19 at 11:42