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 Basics (Retired) Making Decisions with Conditional Statements Document Your Code With Comments

Would having correctGuess=True written out twice count as reptitive code?

.

2 Answers

Steven Parker
Steven Parker
231,268 Points

This is not a case of unnecessarily repeating code. These lines occur inside conditional tests for different things, including testing answers from different questions.

The same job is needing to be done under different conditions, so these lines are not redundant.

He is just giving you an example how nesting works. I think the best way to deal with it is using a loop statement.

Steven Parker
Steven Parker
231,268 Points

I might describe this example as being more about "branching" than "nesting". If it were "nesting", you'd be less likely to see the same variable being updated in several places.