Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Collections and Control Flow Control Flow With Loops Looping Over Ranges

Saad Khan
Saad Khan
7,485 Points

The solution to this challenge?

I am sure this is pretty basic stuff, but for some reason I dont really get what this challenge is asking to do. Any help would be appreciated!!

3 Answers

Saad Khan
Saad Khan
7,485 Points

Never mind, I figured it out. It was pretty silly of me thinking it was actually asking to create a new constant....

this the solution

var results: [Int] = []

for multiplier in 1...10 {

results.append(multiplier * 6)

}

Kelley Muro
Kelley Muro
454 Points

Good catch my friend!

Sarah Waldrop
Sarah Waldrop
461 Points

I still need help with that challenge. it has me stumped.

Michelle Harrison
Michelle Harrison
8,782 Points

I know this is an old comment, but in case anyone else is having issues with it...

You're pretty much doing exactly what he did in the video with the "for in" loop. Except instead of "number", the name is "multiplier"

so for the first part:

 for multiplier in 1...10 {
}

You're leaving it empty because that's what the challenge asks you to do.

The second part (which is what I needed help on):

If you remember from a few videos back, append is to add something to an array. In this case we're adding the results of the variable multiplier (which is the the loop going 1, 2, 3, 4,.....all the way to 10) times(*)6 And it's as Mustafa Taha above said. So you're whole input will look like:

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