Code Lab BetaBUILD. RUN. DISCOVER.
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
JAVASCRIPT DATA / CHAPTER 02 / Learn / LESSON 13
Twelfth class — Data finale. Three report functions:
totalSpent(items) — sum of amount
filterCategory(items, category) — filter by category
remainingBudget(income, items) — income minus totalSpent(items)Sample food 40 + rent 60 + food 15 totals 115; with income 200, 85 remain.
Common mistake: filtering but not returning the array; or remainingBudget subtracting only the first item.
You combine sum, filter, and remaining into one API.
DATA STANDBY
›