Files
30-seconds-of-code/test/toSafeInteger/toSafeInteger.js

2 lines
126 B
JavaScript

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