Tony didn't get any cake

  1. Home
  2. About
  3. Subscribe
  4. Archive
  5. Random

Tony didn't get any cake

Newer
Older
  • Out of retirement and back into Javascript

    Numbers and strings (text)

    In really basic Javascript if you set a variable equal to a number, you need to make sure the number is not inside brackets (” “).

    This could cause the following problem:

    x=5+5;

    x=”5”+”5”

    If you gave the order to:  document.write(x); in the first example it would equal 10 in the second it would equal 55.

    There’s actually a rule here if you add a number to a string the result will always be a string. so:

    5 + “5” will equal 55 as well.

    Posted on July 26, 2009
    Comments (View)
  • blog comments powered by Disqus
  • whatidone
  • throwing-myself-into-the-world
  • brilliant-at-whatever

Field Notes Theme. Designed by Manasto Jones. Powered by Tumblr.