Skip to content

Latest commit

 

History

History
 
 

02.1-maping-array-objects-to-li

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
tutorial

02.1 Mapping array objects to <li>

Using the knowledge you have from the previous example, now lets fix the .map function again, but this time, starting from an array of objects.

const animals = [ { label: 'Horse' }, { label: 'Turtle' }, { label: 'Elephant' }, { label: 'Monkey' } ];

📝 Instructions:

  1. Update the code's .map function to create a new array of <li>'s that each of them corresponds one animal from the original array and

  2. Include them all together inside the website.

Expected result:

const animalsInHTML = [
  <li>Horse</li>,
  <li>Turtle</li>,
  <li>Elephant</li>,
  <li>Monkey</li>
];

💡 Hint:

  • You can use the second parameter of the map function as a key to uniquely identify each html item.

Expected result:

Your website should look like this: Li's