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

It keeps asking me to append my for in loop (multiplier) into the results array variable. I don't now how to do that

Please help

loops.swift
// Enter your code below
var results: [Int] = [1,2,3,4,5,6,7,8,9,10]

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

1 Answer

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

First off your results array should start off as empty as ... well... you don't have any results yet. Then we're going to loop through the numbers one to ten and multiply each by 6. The results array at the end should look like the following [6,12,18,24,30,36,42,48,54,60]. However, you won't be able to tell just by the challenge because you'll never actually print the results. See my code for clarification.

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

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