Name the question first
For totals [20, 35, 15], do we want every adjusted total, only qualifying totals, one result or a yes/no answer? Choosing the shape of the result helps select the method.
const totals = [20, 35, 15];
const doubled = totals.map((total) => total * 2);
const large = totals.filter((total) => total > 20);
const firstLarge = totals.find((total) => total > 20);
console.assert(doubled[0] === 40);
console.assert(large.length === 1);
console.assert(firstLarge === 35);
console.assert(totals.some((total) => total > 30));
console.assert(totals.every((total) => total >= 0));
Map produces one new entry per input. Filter keeps matching entries. Find returns the first match or undefined. Some asks whether any entry qualifies; every asks whether all do. These methods do not themselves mutate the input array, but a callback that mutates an object can still change shared data.
On an empty array, some returns false and every returns true: there is no counterexample. If a rule requires at least one entry, also check length > 0.
Reduce as an optional alternative
const totals = [20, 35, 15];
const sum = totals.reduce((runningSum, total) => runningSum + total, 0);
console.assert(sum === 70);
The final argument 0 initializes the accumulator. Each callback returns the next accumulator. Supplying an initial value handles an empty sum naturally; reduce without one throws on an empty array. A readable loop is equally valid and often easier for more complicated logic.
Independent exercise
Use [5, 12, 20] to keep totals at least 10, add a confirmed fixed charge of 2 to each kept total, then calculate their sum. Predict intermediate results before chaining methods.
Correction
Filtering gives [12, 20], mapping gives [14, 22], summing gives 36. Named intermediate arrays make each step reviewable. A compact chain is optional, not a quality target.
Review
Explain why map is not the right tool for simply printing entries, and why find differs from filter. One returns a single entry or absence; the other always returns an array. The next module introduces objects before using real product records.