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 trialJames Austin
iOS Development Techdegree Student 1,700 Pointsadding multiples to results array from for in loop
I can't seem to understand what this is asking for. It wants the results to contain the first 10 multiples of 6
// Enter your code below
var results: [Int] = []
for multiplier in 1...10 {
print("\(multiplier) times 6 is equal to \(multiplier * 6)")
results.append(multiplier)}
2 Answers
Greg Kaleka
39,021 PointsHi James,
The challenge wants you to put the multiples of 6 into the array (not the multipliers). Multiples of 6 are things that are divisible by 6, so 6, 12, 18, 24, etc. A very small change to your code will fix this.
One other note - be careful of your code formatting. It doesn't matter to the compiler, but it's much easier to understand what's happening in this code:
// Enter your code below
var results: [Int] = []
for multiplier in 1...10 {
print("\(multiplier) times 6 is equal to \(multiplier * 6)")
results.append(multiplier)
}
This will become more and more important as your code becomes more complex. It's a good habit to get into now.
Cheers
-Greg
James Austin
iOS Development Techdegree Student 1,700 PointsI ended up just modify the append statement results.append(multiplier * 6)
This worked out. I do see where itβs easier to read that formatting, will work on dis.
Greg Kaleka
39,021 PointsPerfect - nice work!