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 trialLewis Mansbridge
1,119 PointsHi there, was wondering if i could have some help with some while loops, thank you
I'm really struggling with these loops, has anyone got a guide of some sort of contact i can ask them a few things about, thank you for your help!
let numbers = [2,8,1,16,4,3,9]
var sum = 0
var counter = 0
// Enter your code below
while sum < counter {
numbers // do i add numbers from the Number array up ? CONFUSED ! :(
counter++
}
// THANKS!
2 Answers
Jennifer Nordell
Treehouse TeacherI posted a rather detailed explanation of what this challenge is asking for not long ago. You can check it out here. https://teamtreehouse.com/community/cant-get-through-this-spent-an-hour-on-it-really-feels-instructions-are-unclear-help-please
Hope this helps!
Cindy Lea
Courses Plus Student 6,497 PointsI believe you need to change your while statement to something like while counter < 6 /* can also do: while counter < length(numbers) { sum = sum +numbers[counter]; }
Im not in this class so you will need to verify the length function name: it may be len(). I think the point of the exercise is to add all the numbers up and keeping adding until there are no more numbers. At that point the loop needs to quit.
Lewis Mansbridge
1,119 PointsThanks for the help!!!
Lewis Mansbridge
1,119 PointsLewis Mansbridge
1,119 PointsThank you