Basically I'm trying to see if the rating matches certain criteria then apply certain styles to each star in the list. Problem i'm running into is that only twoStar gets applied to all the list of stars className. How do I apply classname based on criteria match.
const starCluster = <div><FaStar /><FaStar /><FaStar /></div> const starColor = (props) => { props.stardata.forEach((f, i) => { if (f.rating > 1 && f.rating <= 1.9) { return starColor = <div className="oneStar">{ starCluster }</div> } if (f.rating >=2 && f.rating <= 2.9) { return starColor = <div className="twoStar">{ starCluster }</div> } }) return ( <div> <ul> { props.stardata.map((sta, i) => { return <div key={i}> <li > {sta.name} {starColor} </li> </div> } } </ul> </div> } edit:props.stardata is this way
[{name: "sirius", rating: 1.4}, {name: "polaris", rating: 2.4}, {name: "algol", rating: 3.6}]
props.stardata? Thanks