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 trialRichard Pitts
Courses Plus Student 1,243 PointsCan I get some help here?
Can I get some help here?
// Enter your code below
var results: [Int] = []
var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for multiplier in array { 6 * array }
1 Answer
David Papandrew
8,386 PointsRichard,
You only need a single array to which you will append the results of the for-loop.
You use a for-in loop with a range. The multiplier is the temporary variable that holds the iteration value each time the loop is run. So the first time the loop is run, the value of "multiplier" is 1. Second loop it is 2 and so on through 10 (since you defined a range of 1 through 10).
Each loop the multiplier * 6 is appended to the results array.
Hope that helps.
var results: [Int] = []
for multiplier in 1...10 {
results.append(multiplier * 6)
}