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 trial

iOS Swift Collections and Control Flow Control Flow With Loops Working With Loops

I really need help thank you for your time

please give me the answer ive been stuk on this one problem for hours please help

loops.swift
let numbers = [2,8,1,16,4,3,9]
var sum = 0
var counter = 0

// Enter your code below
while counter < numbers.count {
sum += numbers.count
counter += 1
}
while {
sum += numbers.count
}

1 Answer

Jeff McDivitt
Jeff McDivitt
23,970 Points

Hi Rico - Can you stop posting the same question multiple times in the community with a different heading. We are always available for assistance, but you only need to post your question one time. Typically I answer the unanswered questions in the community; however, it is a waster of my time when I am pulling up the same question 4-5 different times. Thank you

No onto the task:

You do not need the numbers.count inside the while loop as that is not what the task is asking. You need to retrieve each value from the array:

let numbers = [2,8,1,16,4,3,9]
var sum = 0
var counter = 0

// Enter your code below

while counter < numbers.count {

sum += numbers[counter]
counter += 1

}

ok thx for ur time srry about that

Chris Stromberg
Chris Stromberg
Courses Plus Student 13,389 Points

I would also like to add that when a correct answer is provided you should return the favor and mark it as correct.