Last active
February 16, 2024 03:36
-
-
Save mnishiguchi/1a686249b63582da2bcef23ecf6671fb to your computer and use it in GitHub Desktop.
n-times loop in React
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
const Stars = ({n}) => { | |
let stars = [] | |
for (let i = 0; i < n; ++i) { | |
stars.push(<i className="fa fa-star" key={i}></i>) | |
} | |
return ( | |
<div className="Stars"> | |
{stars} | |
</div> | |
) | |
} | |
export default Stars |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment