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

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.