parseInt() Method - returns a whole number from a string


Fri Jan 10 2020 19:00:00 GMT+0000 (UTC)

Saved by @goblindoom95 #javascript #jsfunctions #numbers

parseInt("10");         // returns 10
parseInt("10.33");      // returns 10
parseInt("10 20 30");   // returns 10
parseInt("10 years");   // returns 10
parseInt("years 10");   // returns NaN 

parseInt() parses a string and returns a whole number. Spaces are allowed. Only the first number is returned. If the number cannot be converted, NaN (Not a Number) is returned.