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

Zachary Berling
Zachary Berling
10,703 Points

What value and how do I append it? .append() method or the += operator. where do I get the value? Thanks for help :D

This is as far as I've gotten with it i've tried many things but I'm having no luck atm...

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

}

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

}

This code passes Challenge task 1 of 2,

but fails on for Challenge task 2 of 2, giving:

Bummer! 

Your array needs to contain the first 10 multiples. 

Make sure your range goes from 1 to 10

3 Answers

Zachary Berling
Zachary Berling
10,703 Points

I figured it out Nevermind lol

In case Josue is still stuck...

I went with this code:

var results: [Int] = []
for multiplier in 1...10 {
    print("\(multiplier) times 6 is equal to \(multiplier*6)")
    results.append(multiplier*6);

}

...which was based on a slight modification of the

'results.append' code that Steve Hunter (Mod) showed in this forum thread:

https://teamtreehouse.com/community/how-to-find-multiplies-of-7

Josue Gisber
Josue Gisber
Courses Plus Student 9,332 Points

Thanks man, it worked for me! Thanks for the help

Brian Patterson
Brian Patterson
19,588 Points

Thanks for that James. I am finding the challenges in this section confusing.

Zachary Berling
Zachary Berling
10,703 Points

Ended up using the += operator with the results from the loop for the value.