Kizspy | Question: 9
(Choose 1 answer)
How would you combine filter() and map() to display only fruits with names longer than 5 characters and
transform them into uppercase?
A. const items = ["Apple", "Banana", "Cherry", "Avocado"];
return (
<ul>
items.filter(item => item.length > 5).map(item => <li>{item}</li>)
</ul>
);
B. const items = ["Apple", "Banana", "Cherry", "Avocado"];
return(
<ul>
items.filter(item => item.length > 5)
.map(item => <li key={item}>{item.toUpperCase()}</li>)
}
</ul>
);
C. const items = ["Apple", "Banana", "Cherry", "Avocado"];
return (
<ul>
{
items.map(item => <li key={item}>{item}</li>).filter(item => item.length > 5)
);
</ul>
D. const items = ["Apple", "Banana", "Cherry", "Avocado"];
return (
<ul>
}
items.map(item => item.toUpperCase()).filter(item => item.length > 5)
</ul>
);