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

what is the answer looking for?

hi

I feel like I'm getting the answer but its saying Im not doing the first 10 multiples of 6.. I'm looking in the x code and its giving me the first 10 multiples of 6 , I started it from 0 and 1 to 10 ..

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

for multiplier in 0..<10 {
    results.append(multiplier)
    print(multiplier * 6)

}
//(results)

1 Answer

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

Oh you're so close here! Yes, it looks correct in xcode because you're printing what you're supposed to be putting in the array. So it's printing the correct results, but putting in the array the incorrect thing. We want the end array to look like this. [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]. But your array is just putting in multiplier... not multiplier times 6. So your results array (currently) will look like this: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]. Also note that challenges are super picky. If they don't explicitly ask you to print something... don't. 9 times out of 10 it will cause the challenge to fail. Take a look at how close you are!

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

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

Hi Jennifer

thanks for replying so quick - I was trying to get the multiples to print in the array and that was the problem.. multiplying the appended number made it work .. thanks for the help!!