Skip to content

Instantly share code, notes, and snippets.

@mnishiguchi
Last active February 16, 2024 03:36
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mnishiguchi/1a686249b63582da2bcef23ecf6671fb to your computer and use it in GitHub Desktop.
Save mnishiguchi/1a686249b63582da2bcef23ecf6671fb to your computer and use it in GitHub Desktop.
n-times loop in React
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