Numbers

Numbers

  • Used for tasks involving counting or calculating sums

  • Whole numbers (integers) or decimals (floats)

  • Numbers can be negative or positive

  • Numbers do not have quotes around them

There are no commas used when expressing numbers, for example the number 1,750 is expressed as 1750 in Javascript

JS Bin on jsbin.com


Converting Strings to Numbers

  • Sometimes you will find yourself in a position where you need to convert a string to a number

  • This happens when you attempt to read numeric values from html (html displays everything as a string)

  • Use the parseInt() or parseFloat() methods to accomplish this

JS Bin on jsbin.com