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
Sarah Flynn
7,434 PointsFound some errors in this practice session
I'm not sure what the best way for me to share feedback about errors in the course material is. If this isn't the place, please let me know.
While loops practice errors:
doWhileLoops.js
sayswhile
instead ofdo while
throughout the instructionsThe Treehouse solution to the whileLoops practice starting on line 81 of that file is flawed. The instructions require that the loop print the number 8 if it is randomly generated, even if it is generated the first in the sequence. By setting
i
randomly before the loop, you run the risk thati
will equal 8 before we enter the loop and in that case, the loop will not run and 8 will not print. Alternative solution:
// between 0 and 9. Stop building the string when the number 8 comes up.
// Be sure that 8 does print as the last character. The resulting string
// will be a random length.
print('5th Loop:');
text = '';
i = 0;
function randomNum() {
return Math.floor(Math.random() * 10);
}
// Write 5th loop here:
while(i !== 8) {
i = randomNum();
text += i + ' ';
}
print(text); // Should print something like `4 7 2 9 8 `, or `9 0 8 ` or `8 `.
1 Answer

joelearner
54,915 PointsHi Sarah,
When you find a bug, the Support team asks you to send them an email at help@teamtreehouse.com and include a link and a screenshot for the problem.
Cheers!