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 10
Ninth class. .filter keeps only items whose callback returns true.
function foodOnly(items) { return items.filter((item) => item.category === "food"); }
A "rent" record drops out. The result is still an array (maybe empty).
Common mistake: = instead of === in the condition; or a filter that returns item.amount (a number) instead of true/false.
The callback returns true for items that stay.
DATA STANDBY
›