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.
Maybe the energyportion field key is misspelled (it's case sensitive). and/or maybe some items don't have value in this field.
Yes, like J.D. said, be sure that " currentValue.energyportion " has really a value. Do some debuggin to be ensure.
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?
let eSum = $w("#repeater1").data
console.log(eSum);
please post the log.
@Brodwolfsky i get an error though...
@My Dietary Strategies It's the damn duplication bug. Use only one #repeater1 not #repeater1#repeater1
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?
This is an old thread that is partially irrelevant to your question which makes it hard to follow. I'm closing it.
Please open a new post, describe the issue in details and add your code (if you have code)