codex-lv3-may-2025

Kata 18: Fruit List with .map()

Concept: Refactoring list rendering with array methods

We’ve already built FruitList with a manual for loop back in Kata 5. Now let’s revisit that kata and refactor it using the built-in .map() array method.

Challenge

Create a FruitListMap component that:

  1. Uses the same fruit array: ['Apple', 'Banana', 'Orange', 'Grape']
  2. Returns an unordered list (<ul>) with <li> items generated with .map()
  3. Keeps the JSX concise by mapping directly inside the JSX

🔗 Practice on CodeSandbox

Expected Output

• Apple
• Banana
• Orange
• Grape

Starter Code

export default function FruitListMap() {
  const fruits = ['Apple', 'Banana', 'Orange', 'Grape'];

  return (
    <ul>
      {/* Use .map() here */}
    </ul>
  );
}

Hints

Solution

Click to reveal solution ```jsx export default function FruitListMap() { const fruits = ['Apple', 'Banana', 'Orange', 'Grape']; return ( ); } ```

Concept Review


Back to Kata Index