0

As said in the title, I need to add the values of my keys. Here is what I'm doing :

 var repeat=ListeInterv[interv].week_data[numsemaine][intensit];
               for (var i=0;i<repeat;i++)
{tabpush.push(intensit);}
                console.log(tabpush);

For instance (Cardio is intensit):

    { Cardio : 3,
    }

I would have in my array :

[Cardio,Cardio,Cardio]

Then I'll use array.lengh, but I don't think this the best option... I do this because I don't know how to count down the positive values :

{ sport1: 2,
  sport2 : -1,
  sport3 : 1,
}

Answer I would like (in both cases) is : 3

The Array method will be very long (I have a huge amount of data), my method is in an "if" for positive values. Any tips ?

Benoît
  • 143
  • 1
  • 2
  • 15
  • Why is the second example `3`? – Andy May 14 '16 at 18:43
  • I just edited the question because I saw my mistake for looping in array, now I need to add the values of my keys... And the number of key is not fixed. – Benoît May 14 '16 at 18:47

0 Answers0