How to repeat displaying something in JSX
New Courses Coming Soon
Join the waiting lists
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>
→ Get my React Beginner's Handbook
→ Read my full
React Tutorial
on The Valley of Code
Here is how can I help you:
- COURSES where I teach everything I know
- CODING BOOTCAMP cohort course - next edition in 2025
- BOOKS 16 coding ebooks you can download for free on JS Python C PHP and lots more
- Follow me on X