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

ben sasser
ben sasser
476 Points

Im struggling haha....

Just a little bit confused on what exactly it wants me to do... Ive written the append statement but I don't know what to put inside of the array...

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

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

results.append [] 

2 Answers

You were close! The results array should stay empty because you eventually need to append numbers to it.

You got the first part of the for in loop correct. However, inside of the parenthesis, you are appending the product of the multiplier (the numbers in the range 1-10) times 6 to the results array.

I hope this makes sense!

var results: [Int] = []

for multiplier in 1...10 {
  results.append(multiplier * 6)
}
ben sasser
ben sasser
476 Points

thank you so much!

James Knight
James Knight
4,680 Points

var results: [Int] = []

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

I Hope this helps you James

ben sasser
ben sasser
476 Points

thank you so much!