• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 14. Working with Numbers: The Ma... > Converting Between Strings and Numbe...

Converting Between Strings and Numbers

When you're working with numeric expressions in JavaScript, it's important to make sure that all your operands are numeric values. For example, if you prompt the user for a value, you need to check the result to make sure it's not a letter or undefined (the default prompt() value). If you try to use the latter, for example, JavaScript will report that its value is NaN (not a number), as shown in Figure 14.2.

Figure 14.2. If you don't check your numbers, JavaScript may report that a value is NaN (not a number).



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint