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

range not 1...10?

I get an error message that I have to make sure that my range is 1...10

loops.swift
// Enter your code below
var results: [Int] = [6]
for multiplier in 1...10 {

 let multiple = 6 * multiplier
 results.append(multiple)

}

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Ray,

You are on the right track, but there are just a couple of issues here.

  • First, you can't hard code a integer into the results array. You need this array to be empty so that when the results come back in the for loop, it is appended into an empty array. By putting the "6" into the opening declaration, the results will be appended after the 6, and thus, the array now includes another number.

  • Second, inside the for loop you have declared a constant that is not needed. You will do the math 6 * multiplier inside the append method.

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

I hope this makes sense and helps to clarify for you. Keep Coding! :)