[<< Day 3](../30-Days-Of-React/03_Day_Setting_Up/03_day_setting_up.md) | [Day 5 >>](./05_Day_Props/05_props.md)
[<< Day 5](./../05_Day_Props/05_props.md) | [Day 7 >>]()
![30 Days of React banner](../images/30_days_of_react_banner_day_4.jpg)
![30 Days of React banner](../images/30_days_of_react_banner_day_6.jpg)
# Mapping lists
- [Mapping Arrays](#mapping-arrays)
- [Mapping and rendering arrays](#mapping-and-rendering-arrays)
- [Mapping Array of Numbers](#mapping-array-of-numbers)
- [Mapping array of arrays](#mapping-array-of-arrays)
- [Mapping array of objects](#mapping-array-of-objects)
- [Key in mapping array](#key-in-mapping-array)
- [Exercises](#exercises)
Before we jump into mapping an array in React, lets see what we do it in pure JavaScritp.
# Mapping Arrays
[<< Day 4](../04_Day_Component/04_components.md) | [Day 6 >>]()
Array is the most frequent used data structure to handle many kind of problems. In React, we we map an array and modify to list of JSX by adding a certain HTML elements to each element of the array.
## Mapping and rendering arrays
Most of the time data is in the form of array or array of objects. To render this array or array of objects most of the time we modify the data using _map_. In the previous section, we have rendered the techs list using map. In this section also we will also see more examples.
In the following examples, you will see how we render a number array, a string array, a countries array and skills array on the browser.
If you check the the browser, you will see the numbers are attached together in one line. To avoid this, we modify the array and change the array elements to JSX element. See the example below, the array has been modified to a list JSX elements.
### Mapping Array of Numbers
```js
import React from 'react'
import ReactDOM from 'react-dom'
const Numbers = ({ numbers }) => {
// modifying array to array of li JSX
const list = numbers.map((number) => <li>{number}</li>)
Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside the array to give the elements a stable identity. Key should be unique. Mostly data has come with an id and we can use id as key. If we do not pass key react raise a warning on the browser. If the data does not have id we have to find a way to create a unique identifier for each elements when we map it. See the following example:
```js
import React from 'react'
import ReactDOM from 'react-dom'
const Numbers = ({ numbers }) => {
// modifying array to array of li JSX
const list = numbers.map((num) => <likey={num}>{num}</li>)