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 trialJohn Drexler
4,806 PointsCompiler is saying that "while" is unexpected... not sure why
won't compile
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
Console.Write("Enter the number of times to print \"Yay!\": ");
var entry = Console.ReadLine();
var target = int.Parse(entry);
var counter = 0
while (counter < target) {
counter += 1;
Console.WriteLine("Yay!");
}
}
}
2 Answers
stjarnan
Front End Web Development Techdegree Graduate 56,488 PointsHi John!
I think you might be missing a closing bracket there.
Good luck!
John Weber
6,273 PointsI had trouble with this too and I found that every single person on the forums who had solved it was using a 'for' statement, not a 'while' loop.
for(int counter = 0; counter < target; ++counter) {
Console.WriteLine("Yay!")
}
Briain Corroon
13,689 PointsBriain Corroon
13,689 PointsAlso missing a semi-colon after "var counter = 0"