JSX Recipes: How to repeat displaying something in JSX

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


I had the need to repeat something in JSX.

The use case was this, I had a review expressed from 1 to 5 and based on the value I wanted to display some stars, from 1 to 5 stars.

So I used this snippet:

<p>
{[...Array(rating)].map(() => '⭐️ ')}
</p>

Lessons in this unit:

0: Introduction
1: How to render HTML in React
2: Conditional rendering in React
3: How to loop inside React JSX
4: React, how to make responsive JSX
5: ▶︎ How to repeat displaying something in JSX
6: How to move around blocks of code with React and Tailwind