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

Doesn't make snese

I don't know how to solve this or what they are asking for.

loops.swift
// Enter your code below
var results: [Int] = []
for multiplier in results {print(1...10)*6}

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Up at the top they've set up an empty array for you. What they want is for you to use a for loop to start at 1 and go to 10. Every time through the loop you'll add (append) 6 times the number you're currently at. So at the end of your challenge if you were to check the values of the results array you'd have something that looks like this [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]. Here's how we do this:

// Enter your code below
var results: [Int] = []

for multiplier in 1...10 {
    results.append(multiplier * 6);
}

Hope this helps!