Files
30-seconds-of-code/test/toSafeInteger/toSafeInteger.js
2018-08-02 13:49:33 +03:00

4 lines
150 B
JavaScript

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