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 trialJack Potter
418 PointsWhat is wrong with this
What is wrong with this
// Enter your code below
var results: [Int] = [6]
for multiplier in 1...10 {
results.append(multiplier * 6)
}
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! There's not much wrong with it at all except that you've started the array with a number already in it. This means that the array Treehouse is looking at now has one extra 6 in it. Erase the first 6 in the array declaration and your code passes!
Happy coding!
Jack Potter
418 PointsJack Potter
418 PointsThank you Jennifer for your time. One question thou what is the EXACT purpose of an for in loop? (is it to write out the array or is it to create the array
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherJack Potter that depends entirely on what you're going to do with for in loop. In this particular case, we're going through a range of numbers 1 to 10. So it starts at one and goes to 10. The first time through it the multiplier is at 1 and we multiply that by 6 and add it to our empty array. So at the end of this loop our once empty array will look like this [6, 12, 18. 24, 30, 36, 42, 48, 54, 60].
I hope this helps!