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 trialMadison Finck
4,645 PointsHelp. I can't call the document.write more than 1 time. Almost any way I try to fix it comes back with an error.
I'm stuck on adding the document.write to the code. All the ways I have tried have either said error or that it was only called once.
Madison Finck
4,645 PointsThis is my code:
var count = 0; while ( count > 26) { count =+1; }
3 Answers
Julian Aramburu
11,368 PointsHey Madison! As pi R suggested, paste your code here so we can help you out! However on this challenge you are asked to create a while loop that prints using document.write() something 26 times, and you are hinted to use var count = 0; in order to track the times that the loop runs, are you familiar with while loops? are you having problems coding the while loop?
Madison Finck
4,645 Pointsvar count = 0; while ( count > 26) { count =+1; }
pi R
12,720 PointsWell, you're asking it to do the loop while count is SUPERIOR to 26. But count = 0.. so it will never run ! And you need to put document.write() inside your loop {} !
Madison Finck
4,645 Pointsvar count = 0; while (count < 26 document.write () ) { count =+ 1; }
My problem is that I don't know where to put the document.write in my loop.
pi R
12,720 Pointsthe parentheses () are only to evaluate the condition, so yeah you put the count < 26 in this. The code you want to run while the condition is true needs to be inside the curly braces { }
Julian Aramburu
11,368 PointsYou want to document.write() while count is less than 26 so check that! You already added what will break the while loop with count = + 1 , so you only have to execute document.write inside your while loop :).
Madison Finck
4,645 Pointsvar count = 0; while (count < 26 document.write () ) { count =+ 1; }
I got this, I just don't know where the document.write is supposed to go in the while loop.
Julian Aramburu
11,368 Pointsinside the while loop curly braces
var count = 0;
while (count < 26) {
document.write();
count =+ 1;
}
in a while loop you set the condition for the loop to run between the parentesis () and inside the curly braces {} you set what the loop would run if the condition is met... also you need to add something that will cause the loop to break eventually or you will create an infinite loop that will crash your browser. In this case, you are setting the next condition = "do something while count is less than 26" , if that condition is met then the document.write() runs and count gets 1 ...that last part the count += 1 is what will cause the loop to break because at some point count will be greater than 26 so the loop won't run.
pi R
12,720 Pointspi R
12,720 PointsHi ! Show us your code so we can look at it !