reading-notes

Code Fellows courses Notes

This project is maintained by QamarAlkhatib

Passing Functions as Props

React Docs - lists and keys

  1. What does .map() return?
  1. If I want to loop through an array and display each value in JSX, how do I do that in React?

in for loop it will be like this:

let arr = [1,2,3,4,5];

for(let i = 0; i < arr.length; i++){

console.log(arr[i]) ;}


In for Each:

let arr = [1,2,3,4,5];

arr.forEach(element => {

console.log (element);});


in .Map:

let arr = [1,2,3,4,5];

let array = arr.map((element) => {

console.log (element);});


  1. Each list item needs a unique Key.

  1. What is the purpose of a key?

The Spread Operator

  1. What is the spread operator?

  1. List 4 things that the spread operator can do.

  1. Give an example of using the spread operator to combine two arrays.

arrays


  1. Give an example of using the spread operator to add a new item to an array.

objects


  1. Give an example of using the spread operator to combine two objects into one.

objects