0 points

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


dashboard

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

Posted 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 
content_copy

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.





LISTS WITH THIS SNIPPET

>> Browse more code snippets

more_vert