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
  • 741,623
  • 53
  • 500
  • 612
Erick1160
  • 11
  • 2

1 Answers1

0

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

For example:

+'123.456'
GirkovArpa
  • 4,427
  • 4
  • 14
  • 43