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

Carlos Morales
PLUS
Carlos Morales
Courses Plus Student 2,507 Points

"Inside the body of the loop, we're going to use the multiplier to get the multiple of 6" Need Help

What am I doing wrong?

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

for multiplier in 1...10 {multiplier * 6}

results.append (multiplier)

1 Answer

Tobias Helmrich
Tobias Helmrich
31,603 Points

Hey there Carlos,

you were on the right track but the problem is that you have to append the result of multiplier * 6 to the results array inside of the loop. So just write the statement you have in your loop right now as an argument in the append method on the results array and it should work!

Also note that if you append multiplier to the results array outside of the loop it won't work because the multiplier doesn't exist outside of the loop.

This is a working example:

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

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

I hope that helps, good luck! :)