Chapter 12: Array methods
Automation learning lab
Playwright Automation
Self Study Guide
Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.
Array methods
map transforms each item, filter selects matching items, and find returns the first match or undefined. These methods make test data preparation clearer than manual loops when no asynchronous actions are needed.
How it works
Step-by-step walkthrough
- Create numeric scores
- Filter passing scores
- Map to labels
Example
const scores = [40, 80, 95];
const passed = scores.filter(n => n >= 50);
console.log(passed.map(n => `Score ${n}`));map does not wait for promises returned by its callback; use Promise.all where appropriate.
✎ Your practice task
Use find to locate the first score above 90.
Knowledge check
Which method selects matching items?
🌐 Continue learning
60-chapter learning path
Start at chapter 1, or choose any topic. Your progress is tracked separately for each chapter.
JavaScript fundamentals
TypeScript fundamentals
Playwright • setup & locators
Playwright • interactions & assertions
Playwright • framework & debugging
Playwright • real-world automation
Interactive practice lab
Try the controls below and observe the corresponding Playwright locator instructions. This browser demo does not execute Node.js or Playwright Test; copy the code to your local Playwright project to automate it.
Task manager demo
Suggested automation
Actions on the demo update these examples. In your local test use a page that contains the same controls.
Download a standalone lab page, then serve it locally (for example with Python's http.server). Navigate to it in a Playwright test.