I have the following strings in JavaScript as examples:
-77.230202
39.90234
-1.2352
I want to ge the first two digits, before the decimal. While maintaining the negative value. So the first one would be ‘-77’ and the last would be ‘-1’
Any help would be awesome!
Thank you.
You can simply use parseInt().
See it in action – http://jsfiddle.net/ss3d3/1/
Note:
parseInt()can returnNaN, so you may want to add code to check the return value.