I defined JavaScript variables called myData , which is a new Array as follows:
var myData = new Array(['2013-01-22', 0], ['2013-01-29', 0], ['2013-02-05', 0], ['2013-02-12', 0], ['2013-02-19', 0], ['2013-02-26', 0], ['2013-03-05', 0], ['2013-03-12', 0], ['2013-03-19', 0], ['2013-03-26', 0], ['2013-04-02', 21], ['2013-04-09', 2]);
I am wondering if it is possible to sum the numerical values found in the array (e.g. 0 + 0 + 21 + 2 + 0, etc.) and probably a variable with the result that I can use outside the script, because I have 7 such arrays corresponding to each day of the week. I want to make a comparison after this based on this. Is this the most preferred method for this kind of action, if possible?
javascript arrays for-loop sum
Daniela costina Vaduva Apr 17 '13 at 10:28 2013-04-17 10:28
source share