Can someone please give me a correction on this flow...I am trying to sum the values in this example array. Thanks,
[{"id":"e9c32823.c6a048","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"2f47f00c.b8042","type":"inject","z":"e9c32823.c6a048","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":330,"y":260,"wires":[["94b8caa4.e42ab8"]]},{"id":"94b8caa4.e42ab8","type":"function","z":"e9c32823.c6a048","name":"","func":"var testtable = [];\ntesttable[0] = 32455.6;\ntesttable[20] = 31399.6;\ntesttable[40] = 31299.5;\ntesttable[60] = 31280.0;\ntesttable[80] = 31270.0;\ntesttable[100] = 31200.0;\ntesttable[120] = 31155.0;\ntesttable[140] = 31100.0;\ntesttable[160] = 31075.0;\ntesttable[180] = 31000.0;\ntesttable[200] = 30900.0;\ntesttable[220] = 30800.0;\ntesttable[240] = 30700.0;\ntesttable[260] = 30600.0;\ntesttable[280] = 30550.0;\ntesttable[300] = 30485.0;\ntesttable[320] = 30400.0;\ntesttable[340] = 30300.0;\ntesttable[359] = 30100.0;\nmsg.payload = testtable;\n\nfunction sumArray(testtable) {\n for (\n var\n index = 0, // The iterator\n length = array.length, // Cache the array length\n sum = 0; // The total amount\n index < length; // The \"for\"-loop condition\n sum += array[index++] // Add number on each iteration\n );\n return sum;\n}\n\nmsg.payload = sum;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":260,"wires":[["eda574ac.c68238"]]},{"id":"eda574ac.c68238","type":"debug","z":"e9c32823.c6a048","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":930,"y":260,"wires":[]}]