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

Yen Ho
seal-mask
.a{fill-rule:evenodd;}techdegree
Yen Ho
Full Stack JavaScript Techdegree Student 4,708 Points

Ask a Questionplease help me

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

i dont know why it's still wrong.

loops.swift
// Enter your code below
var results: [Int] = []
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

Hi there! You've got your for loop set up correctly, but the challenge explicitly asks you to fill up the results array with the result of multiplier * 6. We do this with the append method. The end result will be that your results array will look like this: [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]. Take a look:

var results: [Int] = []
for multiplier in 1...10 {
  results.append(multiplier * 6)
}

Here we start off with our empty results array. Then we set up our for loop. And these parts you had correct. But the challenge doesn't ask you to print anything. It asks you to put the result in the results array. Hope this helps! :sparkles: