JavaScript Code Completion Medium +20 XP
Array Method Chain
Complete the chain to get names of adults.
JavaScriptFill in the blank
const adults = people
.filter(p => p.age >= 18)
.___((p) => p.name);Type the missing code
Show answer and explanation
Answer: map
The .map() method transforms each element. Here it extracts the name property from each person object.
Hint: Which method transforms each element?
What this challenge tests
Code Completion in JavaScript: array-methods, map.