Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift 2.0 Collections and Control Flow Control Flow With Loops For In Loops

anyone solution about this

anyone solution about this

loops.swift
// Enter your code below
var results: [Int] = []
for multiplier in 1...10 {("\(multiplier) times 6 is equal to \(multiplier * 6)")}
results.append(

3 Answers

Kyler Smith
Kyler Smith
10,110 Points

The task is asking you to create a for-in loop that iterates from the value 1 to the value 10. Then, it asks you to find each multiple of 6 for the values 1 through 10 and append them to the array 'results'. At the end of the second task, your results array should contain the values [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]. Your append statement is almost correct, you just need to put it in the body of the loop so it can be called each time you get a new value from your list.

var results: [Int] = []

for multiplier in 1...10 {
// your code goes here
results.append(/*value you want to append*/)
}

Is this how it should be

var results: [Int] = []

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

results.append(("(multiplier) times 6 is equal to (multiplier * 6)"))

Kyler Smith
Kyler Smith
10,110 Points

Almost, you need to put everything inside your brackets.

for multiplier in 1...10 { /*Everything goes here*/ }

It should look like this.

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

Thanks a lot.