reading-notes

list and keys

  1. What does .map() return?
    • Map returns the new array
  2. If I want to loop through an array and display each value in JSX, how do I do that in React?
    • You would use a {}
  3. Each list item needs a unique __.
    • key
  4. 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.
    • ‘[â€Ķ[“😋😛😜ðŸĪŠðŸ˜â€]] // Array [ “😋😛😜ðŸĪŠðŸ˜â€ ] [â€Ķ“🙂🙃😉😊😇ðŸĨ°ðŸ˜ðŸĪĐ!”] // Array(9) [ “🙂”, “🙃”, “😉”, “😊”, “😇”, “ðŸĨ°â€, “😍”, “ðŸĪĐ”, “!” ]`

const hello = {hello: "😋😛😜ðŸĪŠðŸ˜"} const world = {world: "🙂🙃😉😊😇ðŸĨ°ðŸ˜ðŸĪĐ!"}

const helloWorld = {...hello,...world} console.log(helloWorld) // Object { hello: "😋😛😜ðŸĪŠðŸ˜", world: "🙂🙃😉😊😇ðŸĨ°ðŸ˜ðŸĪĐ!" }

  1. Give an example of using the spread operator to add a new item to an array.
  1. Give an example of using the spread operator to combine two objects into one.

How to Pass Functions Between Components

  1. In the video, what is the first step that the developer does to pass functions between components?
  1. In your own words, what does the increment function do?
    • modifying an array
    • finding the name
    • its going to loop through the array
    • update our stat object
  2. How can you pass a method from a parent component into a child component?
  1. How does the child component invoke a method that was passed to it from a parent component?
    • you toggle it