Files
30-seconds-of-code/test/toSafeInteger/toSafeInteger.js
2018-02-04 17:38:39 +02: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;