Capstone: shopping cart total
Everything so far comes together here: an array of objects, a function that
processes them, and a second function built on the first. This is what most
real application code looks like - not a single trick, but small pieces
composed together.
array.reduce((acc, item) => ..., start) walks the array once, carrying an
accumulator (acc) forward and updating it on each item - perfect for turning
a list into a single total. Once you have that total, the rest is a plain
comparison.
Your task: using the sample cart array already in the editor, write
cartTotal(items), returning the sum of price * qty across all items, and
isBigOrder(items), returning true when cartTotal(items) is 100 or more.
You'll practice:
- Reducing an array to a single value
- Building one function on top of another