Update formatting and description of some older math snippets
This commit is contained in:
@ -10,10 +10,12 @@ Use `Math.round()` to convert to an integer.
|
||||
|
||||
```js
|
||||
const toSafeInteger = num =>
|
||||
Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER));
|
||||
Math.round(
|
||||
Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER)
|
||||
);
|
||||
```
|
||||
|
||||
```js
|
||||
toSafeInteger('3.2'); // 3
|
||||
toSafeInteger(Infinity); // 9007199254740991
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user