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 trialmichael duaybes
431 PointsCollections control Swift 3 basics, how to create an Array for the results produced by For In Loop question
Once you have a value, append it to the results array. This way once the for loop has iterated over the entire range, the array will contain the first 10 multiples of 6. var results: [Int] = []
// Code is below for multiplier in 1...10 { print ("(multiplier) times 6 is equal to (multiplier * 6)")
( I don't know how to produce the array portion from this question.
// Enter your code below
var results: [Int] = []
for multiplier in 1...10 {
print ("\(multiplier) times 6 is equal to \(multiplier * 6)")
}
2 Answers
gmilan
9,287 Points// Enter your code below
var results: [Int] = []
for multiplier in 1...10 {
let myArray = multiplier * 6 //assign this operation to a constant
print ("\(multiplier) times 6 is equal to \(myArray)")
results.append(myArray) // use .append() to fill up var results
}
results // test it out
michael duaybes
431 PointsThank you Gabe, I got it thanks to that. :)