|
Structure values add with JavascriptHello Everybody! I'm posting this topic because i'm quite stuck, due to my lack of skills in javascript. I'm quite shure the thing i want to do might be quite simple but... I have been stuck on it for hours, so i'm coming to you, maybe somebody will know the answer. Here what i want to do: Let's say i have a numbers structure, is there any way to addition all the members, so the output will be the result of all numbers? Ex:
If my structure is: -> My resulting value would be 7 I have found This thread which takes a structure, to return it as a flat structure, which is (i think), not so far from what i want to do. function (__structure arrOut) main (__structure arrIn, __number n) { var result = new Object(); var arrNew = new Array(); var arrTemp= new Array(); if(!_testMode) { for(i=0;i<arrIn.length;i++) { arrTemp[i]=arrIn[i]; } for(var i = 0; i < arrTemp.length; i += n) { arrNew.push(arrTemp.slice(i, i+n).join(" ")); } } result.arrOut = arrNew; return result; } But i can't get to change the good parts to make it work, so any help would be highly appreciated!
|
Easy stuff, just google general javascript stuff and think of the __structure as an array.
Might be other ways to do it, i'm no js expert, but this'll do.
Oh yes many thanks!
I know i need to get into learning javascript tough!
Thank you