From the course: JavaScript: Arrays
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Reformat data with map - JavaScript Tutorial
From the course: JavaScript: Arrays
Reformat data with map
- [Instructor] Have you ever been presented with an array that isn't quite what you need? It has all the necessary data but that data just needs a little bit of massaging. Let's take this array of grades as an example. You have the grades and they all need to have five points added to them. This is where the array method map comes in. The map array method generates a new array based on the function applied to each element in the array you're iterating over. The syntax for maps should look really familiar. We have seen the same syntax with for each, find, find index, and a few other array methods. So hopefully that will help you grasp how to get started with using map. The only difference you might notice is that we have the array method set to a new variable. This variable can be named whatever you'd like and whatever is relevant for your code. We'll call it new here since we're returning a new array. Before we move on to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.