Map Filter Chain in JavaScript
Level 4237 keystrokes
Chaining filter and map methods allows for clean data transformation pipelines.
JavaScript code
// Array of products with name and price1const products = [2 { name: "Book", price: 15 },3 { name: "Pen", price: 3 },4 { name: "Laptop", price: 999 },5 { name: "Mouse", price: 25 }6];// Chain filter and map methods7const affordable = products // Filter products under $508 .filter(p => p.price < 50) // Map to just product names9 .map(p => p.name);// Output: ['Book', 'Pen', 'Mouse']10console.log(affordable);Output
[ 'Book', 'Pen', 'Mouse' ]
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this JavaScript code and how often they appear.
:× 8"× 8,× 7.× 5{× 4}× 4=× 4;× 3(× 3)× 3