Higher Order Functions

map Transforms Items

map Transforms Items

map creates a new array by transforming each item from the original array. The callback decides what each new item should become.

The original array is not changed. That makes map a good fit when UI code needs display labels, URLs, or view models derived from existing data.

Your task: Use map to create topicLabels from topics. Each label should include the topic name and its position number for display.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

map Transforms Items

map creates a new array by transforming each item from the original array. The callback decides what each new item should become.

The original array is not changed. That makes map a good fit when UI code needs display labels, URLs, or view models derived from existing data.

Your task: Use map to create topicLabels from topics. Each label should include the topic name and its position number for display.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Console

Run code to see output.