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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![David Rhodes](https://secure.gravatar.com/avatar/5fffd03c17e5a440d07470d5bdc703ce?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
David Rhodes
Courses Plus Student 2,352 PointsWhy don't my results write to the index.html doc?
On the loops exercise and for the life of me and after an hour of checking, cannot figure out why this code doesn't work. I got it right the first time I thought, then checked against the instructor's explanation code five times. Still no love:
var upper = 10000;
var randomNumber = getRandomNumber(upper);
var guess;
var attempts = 0;
function getRandomNumber(upper) { return Math.floor( Math.random() * upper ) + 1; }
while (guess !== randomNumber) { guess = getRandomNumber(upper); attempts += 1; }
document.write("<p>The random number was: " + randomNumber + "<p>"); document.write("<p>It took " + attempts + " attempts to guess the correct number.</p>";
4 Answers
![Niilo Smeds](https://uploads.teamtreehouse.com/production/profile-photos/4407492/micro_1376887-harpo_marx_5.jpg)
Niilo Smeds
12,540 PointsYou're just missing a closing parenthesis before your very last semicolon:
document.write("<p>The random number was: " + randomNumber + "<p>"); document.write("<p>It took " + attempts + " attempts to guess the correct number.</p>");
![David Rhodes](https://secure.gravatar.com/avatar/5fffd03c17e5a440d07470d5bdc703ce?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
David Rhodes
Courses Plus Student 2,352 PointsThanks Niilo, and Idan. I added parentheses...saved, still doesn't work. At a loss here. Will try codepen.io to see if it's something wonky with the learning environment. I did try closing all workspaces and restarting Chrome.
![Niilo Smeds](https://uploads.teamtreehouse.com/production/profile-photos/4407492/micro_1376887-harpo_marx_5.jpg)
Niilo Smeds
12,540 PointsA good way to troubleshoot is to paste the code at codepen.io or in any modern text editor. Most of those tools offer real-time error-checking.
![Niilo Smeds](https://uploads.teamtreehouse.com/production/profile-photos/4407492/micro_1376887-harpo_marx_5.jpg)
Niilo Smeds
12,540 PointsHmm, maybe it's a workspace issue. The code worked for me when I pasted to Codepen and added the parenthesis.
![David Rhodes](https://secure.gravatar.com/avatar/5fffd03c17e5a440d07470d5bdc703ce?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
David Rhodes
Courses Plus Student 2,352 PointsIt's definitely a workspace issue: Sometimes you have to restart Chrome AND click shift to refresh the cache when opening the preview page. Glad it's not me (this time)...thanks guys for the quick responses!! Have a great weekend. -David
Idan Melamed
16,285 PointsIdan Melamed
16,285 PointsYou might be missing a closing parenthesis on your last document.write