Files
30-seconds-of-code/snippets/validate-number.md
2017-12-12 07:11:37 -05:00

9 lines
235 B
Markdown

### Validate number
Use `!isNaN` in combination with `parseFloat()` to check if the argument is a number.
Use `isFinite()` to check if the number is finite.
```js
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n);
```