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

Dawson Young
Dawson Young
512 Points

Super lost on this code challenge :(...

Cannot figure out the last part of this step

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

for multiplier in 1...10 {
"\(multiplier) times 6 is equal to \(multiplier * 6)"
}
results.append(multiplier)

2 Answers

Tobias Helmrich
Tobias Helmrich
31,603 Points

Hey Dawson,

the problem is that you're appending the multiplier to the results array outside of the for in loop where the multiplier doesn't exist. Also you would just be appending the multiplier but not the multiples of 6. You should append the multiples of 6 to the array inside of the for in loop which you do like this:

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

I hope that helps, if you have further questions feel free to ask! :)

Dawson Young
Dawson Young
512 Points

WOW that makes sense now. Thanks Tobias you are a huge help bro!!!!!!!! You're really good at coding

Tobias Helmrich
Tobias Helmrich
31,603 Points

Haha, thanks for the compliment! :) I'm always happy to help and I'm glad that it makes sense for you now!

Kevin Elliott
Kevin Elliott
15,653 Points

It's unclear here what you need to do. What is the problem statement?