I have a problem for the level 1 course

Hey everyone,
I want to pass the badge for level 1, but for the last step I can’t get the bookedSum, here is the result

here is the the code in the code node:
let items = $input.all();
let totalBooked = items.length;
let bookedSum = 0;

for(let i=0; i < items.length; i++) {
bookedSum = bookedSum + items[i].json.orderPrice;
return [{json:{totalBooked, bookedSum}}];

Can somebody help me, please?

Hi @min_gao, welcome to the community!

How does your workflow look like? Which data are you sending to your Code node?

Hi @MutedJam,
My data stocked in Airtable with format number.

the workflow, you can find here

Maybe it’s the problem of format?
Thank you,

Thanks @min_gao! It seems to me the orderPrice field lives under fields. So I’d try replacing bookedSum = bookedSum + items[i].json.orderPrice; in your line 5 with this:

bookedSum = bookedSum + items[i].json.fields.orderPrice;

Perhaps you can give this a go on your end and let me know if that returns a bookedSum value for you?


@MutedJam Yes you are right, I try it, now I have the correct result.
Thank you so much :). Have a nice day.

1 Like

Sweet, glad to hear and thanks for confirming :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.