1

What I was able to find while looking through stackoverflow was that this is the best way to prompt a string and turn it into a number. Is this the best way? Thank you!

var age = prompt("Please enter your age:");
if (Number(age) < 18) {
  alert("");
}
Barmar
  • 669,327
  • 51
  • 454
  • 560
Erick1160
  • 11
  • 2

1 Answers1

0

Prepend a + to it. That's the simplest way.

For example:

+'123.456'
GirkovArpa
  • 3,841
  • 4
  • 7
  • 33