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 trialJamal Ayton-Brown
1,606 PointsReally stuck!
Hey guys,
I'm at a loss at why I'm unable to get past the second stage of this challenge?
Would be really helpful if anyone could shed some light!
let numbers = [2,8,1,16,4,3,9]
var sum = 0
var counter = 0
// Enter your code below
while counter < 6 {
numbers.count
counter++
}
while counter < numbers.count {
sum = sum + numbers[counter]
counter++
}
2 Answers
Alexander Smith
10,476 PointsIf you haven't got it already, just omit your first while loop, your second one is correct
let numbers = [2,8,1,16,4,3,9]
var sum = 0
var counter = 0
// Enter your code below
while counter < numbers.count {
sum = sum + numbers[counter]
counter++
}
Jamal Ayton-Brown
1,606 PointsThanks Alexander!