Day 9 of 100: Array Power Methods — map, filter, reduce, find
Day 9 of 100 — 100 Days of Playwright with TypeScript Challenge. Phase: JavaScript Fundamentals. JavaScript (Days 1-33) → TypeScript (Days 34-63) → Playwright (Days 64-96) → AI Framework Capstone (Days 97-100).
🎭 Want to master this with real projects? Join the Playwright Automation Mastery course at The Testing Academy.
map, filter, find, reduce, some, every — six methods that replace 80% of loops in test code.
Contents
The Big Six
const responses = [
{ url: '/users', status: 200, ms: 120 },
{ url: '/orders', status: 500, ms: 80 },
{ url: '/items', status: 200, ms: 450 },
];
// map — transform each
const urls = responses.map(r => r.url);
// filter — keep matching
const errors = responses.filter(r => r.status >= 400);
// find — first match
const slow = responses.find(r => r.ms > 400);
// some — at least one?
const hasErrors = responses.some(r => r.status >= 400); // true
// every — all match?
const allFast = responses.every(r => r.ms < 500); // true
// reduce — accumulate
const totalMs = responses.reduce((sum, r) => sum + r.ms, 0); // 650
🚀 Level Up Your Playwright
From locators to CI pipelines — build a production-grade Playwright + TypeScript framework step by step.
Chaining for Assertions
// 'Get names of all failing endpoints'
const failingUrls = responses
.filter(r => r.status >= 400)
.map(r => r.url);
// ['/orders']
// Real Playwright usage:
// const texts = await page.getByRole('listitem').allTextContents();
// const active = texts.filter(t => t.includes('Active'));
Tomorrow (Day 10): Objects — the shape of every API payload.
🎓 Master Playwright End to End
Join hundreds of SDETs building real automation frameworks. Lifetime access, hands-on projects, and a job-ready portfolio.
