hey guy hoping someone could help a coding noob such as myself figure this one out. I have and array of “ingredients”, each “ingredient” is itself any array with macronutrient values. id like to be able to loop through the array and add each macronutrient together for a total displayed at the bottom of my screen. any help would be greatly appreciated/hope i explained correctly.
var result = 0
for(var item of Inputs.Items) {
result += parseFloat(item.Protein)
}
Outputs.Result = result
One tricky thing is that your values are actually strings (you can see that since they are listed in " " in the inspector). So you need the parseFloat function to convert them to numbers so you can add them up. (otherwise, the += would just concatenate the strings)