scrimba
React Fundamentals - Components & Props
Lists and Keys Exercise
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Lists and Keys Exercise
AboutCommentsNotes
Lists and Keys Exercise
Expand for more info
PetCard.js
run
preview
console
import React from 'react'

// render a <li> for each element in the favSnacks array
// remember to use a unique key prop

function PetCard(props) {
console.log(props)
return (
<div className="card">
<h2>{props.name}</h2>
<img src={props.image} alt={props.name} />
<h3>Favorite Snacks</h3>
<ul>
{/* render snacks here */}
</ul>
</div>
)
}

export default PetCard
Console
{name:
"Fezzik"
, image:
"https://s3.amazonaws.com/cdn-origin-etr.akc.org/wp-content/uploads/2017/11/23124207/Old-English-Sheepdog-running-in-the-park.jpg"
, favSnacks:
[
"Peanut Butter"
,
"Soccer Balls"
]
}
,
{name:
"Lucy"
, image:
"https://emborapets.com/wp-content/uploads/2020/08/Why-Does-My-Springer-Spaniel-Smell-So-Bad_.jpg"
, favSnacks:
[
"Cake"
,
"Bacon"
]
}
,
{name:
"Blaise"
, image:
"https://www.thesprucepets.com/thmb/P8d4QM0bI4rJh1WygZDI8f8kNV4=/1000x1000/smart/filters:no_upscale()/GettyImages-870255568-8639765b08c6441dbe35ed72e2d8fb48.jpg"
, favSnacks:
[
"Pigeons"
,
"Grass"
,
"Chicken"
]
}
,
/index.html
-5:53