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 trialArief Widyananda
16,129 Pointsneed answer for in loop challenge task 2 of 2
please help me, i don't understand why my answer still a bummer!
// Enter your code below
var results: [Int] = [1,2,3,4,5,6,7,8,9,10]
for multiplier in 1...10 {
results.append(multiplier * 6)
}
3 Answers
jcorum
71,830 PointsArief, the instructions can sometimes be a bit ambiguous. The challenge wants multiplier to be a constant set to the value 6. And it needs to be declared and initialized outside the loop:
var results: [Int] = []
let multiplier = 6
for i in 1...10 {
results.append(multiplier * i)
}
P.S., you don't put the values in the array ahead of time. You let the loop do that.
Arief Widyananda
16,129 Pointsthanks for the answer, i'll try that codes
jcorum
71,830 PointsNot sure if I understand your most recent post, but the array must be empty at the beginning.
Arief Widyananda
16,129 Pointsyup, you got it right. when i erase the array at the beginning it is correct answer... thanks