Calculation......

Discussion in 'JavaScript' started by Namuk, Mar 15, 2008.

  1. #1
    i got a problem about calculation...
    this is my problem...

    $score = 0;

    //this is come form random choose by computer.
    if(condition)
    {
    $result = 1;
    }
    elseif(condition)
    {
    $result = -1;
    }
    else
    {
    $result = 0;
    }

    //calculate the value of result as score.
    $score +=$result

    i want to this repeat calculate as long as i need...
    but i need the $score will be change value to the next calculation.

    example;
    //first calculate
    $score = 0
    $result= 1

    so $score +=$result = 0+1 = 1

    //second calculation
    $score=1 //come from first calculation
    $result=1

    =2

    //third calculation
    $score =2 //come from second calculation
    $result=-1

    =1


    so how do i change the value of $score after calculation to be the total value
    and bring it to the next operation.

    please help me... i have try so many time but i don't, how to change it....
    the value of $score do not change.....

    thanks.....
     
    Namuk, Mar 15, 2008 IP
  2. Namuk

    Namuk Peon

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    any other suggestion?....:confused:
     
    Namuk, Mar 15, 2008 IP