I want to achieve this <div>©©©©</div>
using js, I tried with <div>{"©".repeat(4)}</div>
but the result is one string inside the tags <div>"©©©©"</div>
I want to achieve this <div>©©©©</div>
using js, I tried with <div>{"©".repeat(4)}</div>
but the result is one string inside the tags <div>"©©©©"</div>
2
Answers
I’m assuming you want to do this programmatically,
map
is one solution:Call
{generateNeededDiv(4)}
in the JSX where you need it. Alternatively, if you don’t want to use a function, you can take the div being returned and hardcode it to 4. The code withArray.apply(null,Array(number))
is just initializing an empty array you can iterate over.You can render an array of fragments: