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

Brian Patterson
Brian Patterson
19,588 Points

Don't understand what the question is getting at.

Again this is really badly put. I don't understand what you mean? I have got the first part of the challenge correct but what are you asking me to do now. I might as well being reading it in French.

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



for results in 1...10 {
    let multiplier = results * 6
    multiplier * 1

}

1 Answer

Pasan Premaratne
STAFF
Pasan Premaratne
Treehouse Teacher

Ok so I think you glossed over the directions because even the first part of your code is incorrect (although correct enough to pass the first section).

  1. Your task for this step is to create a for in loop that iterates over a range. For the loop you're writing, name this constant multiplier.

We went over temporary constants in for loops in the video right before this. You've named the temporary constant "results". This is incorrect.

  1. Inside the body of the loop, we're going to use the multiplier to get the multiple of 6. For example, if the multiplier is 1, then the multiple is 1 times 6, which is equal to 6. This is referring to the multiplier constant you create in the first part of the for loop. Not a constant you create inside the loop.

For loops iterate over a range of values. Written correctly this for loop will range over the values from 1 - 10 and assign each value to the constant multiplier. Use this value that is assigned to multiplier to compute the desired value.

  1. Once you have a value, append it to the results array. You aren't appending anything to the array.

I encourage you to carefully think about the purpose of the question, i.e, to end up with an array that contains the first 10 multiplies of 6.

Try it again and if you're still stumped, I'll provide further hints

Brian Patterson
Brian Patterson
19,588 Points

var results: [Int] = []

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

} Still stumped! Still not clear and have been totally been flummoxed by this question.