React | Lists and Keys | Question 8

Last Updated :
Discuss
Comments

What is the output of the following code?

JavaScript
const items = ['Apple', 'Banana', 'Apple'];
return (
    <ul>
        {items.map((item, index) => <li key={index}>{item}</li>)}
    </ul>
);

A list with duplicate keys

A list with unique keys

A list with no keys

An error due to duplicate keys

Share your thoughts in the comments