React Fundamentals

0% completed

Previous
Next
Quiz
Question 1
What is the correct way to render a list in React?
A
Using the map() function inside JSX
B
Using a for loop directly inside JSX
C
Using the filter() function inside JSX
D
Using document.createElement()
Question 2
Why is it recommended to include a key prop when rendering lists in React?
A
To ensure the list is displayed in alphabetical order
B
To help React efficiently update and re-render list items
C
To enable inline styles for list items
D
To prevent duplicate values in the list
Question 3
What should typically be used as a key when rendering dynamic lists?
A
The index of the item in the array
B
A randomly generated number
C
A unique and stable identifier, like an ID
D
The length of the array
Question 4
What is the correct way to conditionally render an item in a list?
A
{items.map(item => if (item.active) <li>{item.name}</li>)}
B
{items.map(item => item.active && <li>{item.name}</li>)}
C
{items.forEach(item => item.active ? <li>{item.name}</li> : null)}
D
{if (items.length > 0) items.map(item => <li>{item.name}</li>)}

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next