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 trialJihong Min
2,156 PointsAlmost done but stuck... please help!
The complier keeps giving me this msg and I don't know what to do from here. " Make sure the results array contains the first 10 multiples of 6"
// Enter your code below
var results: [Int] = []
for multiplier in 1...10 {
results = [multiplier * 6]
}
1 Answer
Rogier Nitschelm
iOS Development Techdegree Student 5,461 PointsYou are currently reassigning the results variable in every iteration. This means that the result will be:
[6] // first iteration
[12] // second iteration
[18] // third iteration
# ...
[60] // and eventually
This means the result will be [60] (the last assignment inside the loop).
Instead of trying to reassign the results-variable in every iteration, you want to add an element to it in every iteration. See if you can use the .append
method to do this. Instead of results = [...]