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?

Programmeur
  • 1,483
  • 4
  • 22
  • 32

1 Answers1

7

Just do

parseInt(yournumber, 10)

PSL
  • 123,204
  • 21
  • 253
  • 243
  • 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
  • const num = 14.56789; const beforeDecimal = Math.trunc(num); console.log(beforeDecimal); // ️ 14 – Meisan Saba Jan 16 '23 at 05:52