React · Junior · Question 17 of 75

What is rendered if items = []?

<div>{items.length && <List items={items} />}</div>

Explanation

0 && x returns 0, and React renders numbers as text (unlike false, null, undefined). Write an explicit boolean condition: items.length > 0 && ... or a ternary items.length ? <List /> : null.

Further reading

Problem with a question

React · Junior · question 17

Test yourself

Take the React · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz