iOS Swift Collections and Control Flow Control Flow With Loops For In Loops

Rabbie Wordie
Rabbie Wordie
1,441 Points

Not sure how to get the equation results too append into the "results" array.

Is the loop body even correct?

// Enter your code below
var results: [Int] = []

for multiplier in 1...10 {
  print("\(multiplier) times 6 is equal to \(multiplier * 6)")


1 Answer

Michael Hulet
Michael Hulet
Treehouse Moderator 47,818 Points

You have all the right building blocks here to pass the challenge, though they're not all in the right place. First of all, this challenge doesn't require you to print anything. All you need to do is append to the results array. You've already written some good code to do that, but it's outside the loop (the multiplier constant is only valid within the loop, and not outside). That being said, don't forget to multiply your multiplier by 6 before you append it (which is something you've done correctly at the end of the print you have)!

Once you combine those couple things, you should be good to go