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 JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Build a Quiz Challenge, Part 2 Solution

Nick B.
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Nick B.
Full Stack JavaScript Techdegree Graduate 31,101 Points

Add more conditional statements at the end?

Pardon my English first of all, I'm just curious, would it be better to add more conditional statements at the end like this?

    html = 'You got ' + correctAnswer + ' question(s) right.';
    if (gotRight.length) {
        html += '<h2>You got these questions correct:</h2>';
    html += buildList(arrayofRightAnswers);
    }
    if (gotWrong.length) {
    html += '<h2>You got these questions wrong:</h2>';
    html += buildList(arrayofWrongAnswers);
    }
    print(html);

So, if the users don't get either right or wrong answer at all. The <h2> "You got these questions" won't show up.