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 trialFrank Grillo
Front End Web Development Techdegree Graduate 16,715 PointsCreating a for loop
Is this how I create a for loop?
for ( let counter = 5; counter <= 100; counter += 45 ) {
console.log(counter);
}
1 Answer
Mark Sebeck
Treehouse Moderator 37,799 PointsHi Frank. Yes that is the proper format for a for loop. But Iβm confused why are you counting by 45? You want all number 5 to 100. So you start at 5 and count while counter <= 100. thatβs all correct. But you want to count by 1. not 45. counting by 45 will give you the output: 5 50 95.
You want to end your for loop with: counter += 1
Not counter += 45