TestingDocs.com logoTestingDocs.com
Automation learning lab
TestingDocs • Self-paced course

Playwright Automation
Self Study Guide

Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.

60 chaptersBeginner friendlyHands-on practice
JavaScript / Chapter 12 of 60~12 min • Beginner
Chapter 12JavaScript

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

  1. Create numeric scores
  2. Filter passing scores
  3. Map to labels

Example

JavaScript
const scores = [40, 80, 95];
const passed = scores.filter(n => n >= 50);
console.log(passed.map(n => `Score ${n}`));
Expected result: ['Score 80', 'Score 95']
💡 Point to remember
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