https://leetcode.com/problems/string-to-integer-atoi/

1
2
3
4
5
6
7
/**
* @param {string} str
* @return {number}
*/
var myAtoi = function(str) {
return Math.max(Math.min(parseInt(str, 10) || 0, 2147483647), -2147483648);
};