Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Solution: Render the Stars

rendering 2 sets of 5 stars

import React, { useState } from 'react';
import Star from './Star';

const StarRating = () => {

    const renderStars = () => {
        let stars = [];
        const maxRating = 5;
        for ( let i = 0 ; i < maxRating ; i++) {
            stars.push (
            <Star
            key={i}
            />
            );
        }
        return stars;
    }



    return (
        <ul className='course--stars'>
            { renderStars()}
        </ul>
    );
}

export default StarRating;

why is it rendering two sets of 5 stars?

2 Answers

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Data Analysis Techdegree Graduate 49,443 Points

Was there any changes made to the Course.js file? Just want to make sure there's not two StarRating components written in it's return statement. The code you provided does seem to look just like Laura's solution in Video 2.

yup I totally wrote it twice in the course.js file thanks!