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!
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
Jayson Di Pietro1,404 Points
Why do you have to add questionsLeft again after every prompt?
Why do you have to add questionsLeft again after every prompt? Why can't i just add
questions -= 1 after every prompt like the example below? If I do not add:
questions -= 1;
questionsLeft = " (" + questions + " questions left)"
questions variable does not decrease by 1.
Steven Parker225,770 Points
The "questionsLeft" string tells the user how many questions are left to answer, and to be accurate it must be re-created for each question. Simply reducing "questions" doesn't change the message that will be shown.