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 2.0 Collections and Control Flow Control Flow With Loops For In Loops

needing help on the first part of the code challenge

I'm not sure what the question is asking me to do for the first part of the code challenge

1 Answer

David Papandrew
David Papandrew
8,386 Points

Hi Jared,

The challenge wants you to use a for loop with a range. On each loop you will multiply the a counter (in the code below this is "x") by 6. Since your loop iterates from 1 through 10, "x" increments with each loop. The first loop it equal 1, then 2, then 3, etc. You will then append the product of 6 * x to the results array.

Here is how you can accomplish this:

for x in 1...10 {
    let multiplier = 6
    results.append(x*multiplier)
}