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

235 B

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.

const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n);