Logo
Section 1 / 10

购物车总价:练习

编写一个无参函数来计算购物车的总价(以美元为单位)。

导入

购物车总价:练习

编写一个无参函数来计算购物车的总价(以美元为单位)。

计算购物车的总价(以美元为单位)。

用法

1const price = getTotalPrice(cart); // '$44.20'

你的解决方案必须是无参的(point-free)。

1import {} from 'ramda'; 2import cart from './cart'; 3 4const getTotalPrice = () => {};

条件逻辑

购物车总价:解决方案回顾