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

Matt Martin
Matt Martin
1,225 Points

How do you append the results to the array? I am stuck and having issues with the code challenge.

I can print out the multiplier * 6, but I cannot append those results to the results array.

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

for multiplier in 1...10 {
    results = [(multiplier * 6)]
}

2 Answers

Matt Martin
Matt Martin
1,225 Points

Tom Achki Thanks for the help! I had just figured it out when I got your message. I also learned you can solve the issue this way -

var results: [Int] = []

for multiplier in 1...10 { results += [multiplier * 6]