Files
30-seconds-of-code/test/toSafeInteger/toSafeInteger.js
2018-01-17 13:40:40 -05:00

3 lines
147 B
JavaScript

const toSafeInteger = num =>
Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER));
module.exports = toSafeInteger