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!

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

Jarren Bird
Jarren Bird
8,125 Points

l can't tell what I'm doing wrong here.

According to my playground version of this code I am filling the results with the correct data, but when I click check my work it says that I haven't configured my code correctly. What am I missing?

// Enter your code below
var results: [Int] = []
for multiplier in 1...10 {
  print("\(multiplier) times 6 equals \(multiplier * 6)")
Jarren Bird
Jarren Bird
8,125 Points

I figured it out. I wish the "get help" button wouldn't just force me to ask a question, but also suggest other questions students have had with the same code challenge.

The problem was I was misunderstanding what the code challenge meant by finding the "multiple of 6." I thought that meant that I needed to fill the results array with [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]. If that had been the case, my code would have been right.

What the code challenge actually wanted, however, was the multiples of 1-10 * 6 which are [6, 12, 18, 24, 30, 36, 42, 48, 54, 60].

My line was almost right. The change I made that made it correct was:

results.append(multiplier * 6)

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

I'm like you, Jarren. What I actually wish is that the "Get help" would be a drop down menu that could either take you to posting your question or do an automatic search for people that have had problems in that particular challenge. It seems like the search is already in place. If you go up to the top of this post and right click on the "For in loops" and open in a new tab it will take you to a place with no less than four pages of answers to exactly this challenge. Let's hope it becomes a reality someday!

P.S. Big kudos on figuring out yourself!

Jarren Bird
Jarren Bird
8,125 Points

Thanks for the tip, Jennifer. That will be super helpful.