#Help me with this anyone

11 messages · Page 1 of 1 (latest)

sinful thorn
#

const totalRevenue = paidOrders.reduce((total, order) => {
const orderTotal = order.orderItems.reduce((orderSum, item) => {
return orderSum + item.product.price.toNumber();
}, 0);

IN .TONUMBER() IT SHOWS THIS ERROR
Property 'toNumber' does not exist on type 'number'.ts(2339)
any
does anybody know this error

pearl narwhal
#

Here are two ways of doing this:
You can use the Number() function. Example: Number(item.product.price)
OR
You can use the parseInt function. Example: parseInt(item.product.price)

Try these out and see if it fixes the error

pearl narwhal
#

The same error? Property 'toNumber' does not exist on type 'number'.ts(2339)?

sinful thorn
#

Argument of type 'number' is not assignable to parameter of type 'string'.ts(2345)

pearl narwhal
#

Which of the two methods did you use? Number() or parseInt()?

sinful thorn
#

both

#

thanks mate it works

pearl narwhal
#

To me it seems like item.product.price is already a number

sinful thorn
#

it was number i have to put () at the end