Web Analytics Made Easy -
StatCounter How to reset a variable - CodingForum

Announcement

Collapse
No announcement yet.

How to reset a variable

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to reset a variable

    Ok this might sound like a stupid question... but how do you erase the value of a varaible? I have:

    Code:
     myvar = ""
    myvar += "this is a test"
    this works once but when I try to run it again; since myvar is defined when I have

    Code:
    myvar = ""
    it just dies. Unless does anyone know how I can make this work?

  • #2
    It might be easier if you show us exactly what you are trying to do, but you probably want to put in into a loop:

    Code:
    var = 0
    while (var < 5) {
    var ++ 
    alert(var)
    }
    Start a fire for a man and he will be warm for a night, set a man on fire and he will be warm for a lifetime.

    Comment


    • #3
      sorry guys... stupid mistake...
      I had my function name and my variable name be the same thing so the comp got confused

      Comment

      Working...
      X