Home > shorts > Compare two numbers with JavaScript

Compare two numbers with JavaScript


If you want to compare two numbers, but one of them has a type of string. You can use ">" or "<" signs. It'll convert string to a number.

1 < '2' // true
© 2021, Andrew Losseff