I want to repeat "★" as many times as a number in state in React.
What should I do?
I want to printing like this.
js ★★★
ts ★★
html ★★★
state = {
myScores: [
{ name: "js", score: 3 },
{ name: "ts", score: 2 },
{ name: "html", score: 3 }
]
}
...
const myScores = this.state.myScores.map(
({name, score}) => (
<div>
{name}
{
for(let i=0; i<score; i++) {
<div>★</div>
}
}
</div>
)
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>