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 ?