Hi,
I am trying to add the total amount of each nutrients that is in a repeater but can't seem to get it right. Am starting with energy. I ended up getting this: NaN[object Object]undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined[object Object]undefinedundefinedundefinedundefinedundefinedundefinedundefined
Here is the code that I did:
import wixData from 'wix-data'; $w.onReady(function () { $w("#dataset1").onReady(() => { let IeSum = 0; let eSum = $w("#repeater1").data.reduce( (accumulator, currentValue) => accumulator + currentValue.energyportion, IeSum); $w("#ESum").text = eSum.toString() console.log("addedEnergy") }) })
// and other filter codes below this...
Am I doing something wrong?
Thanks.
Hi, I am getting the same thing, as seen in the photo below.
When I try to add the price from a repeater ( bbq and balcony, price 45 and 35), it gets many values. Were you able to fix the issue?
Thank you J.D. and Brodwolfsky. I've checked and it wasn't misspelled. I have also checked the fieldType and it is a number... I am guessing it is because I am filtering my repeater therefore I have that error? Could that be a possibility?
Yes, like J.D. said, be sure that " currentValue.energyportion " has really a value. Do some debuggin to be ensure.
Maybe the energyportion field key is misspelled (it's case sensitive). and/or maybe some items don't have value in this field.