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

Juan Jimenez
Juan Jimenez
4,389 Points

I don't understand what it means to append to the results array.

I can get the first step

for multiplier in 1...10 {}

but I don't understand what the next step is asking for.

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

for multiplier in 1...10 {multiplier * 6}

1 Answer

Steven Parker
Steven Parker
195,447 Points

When they say "append to the results array" they mean add it as a new element in the array named "results".

But it's also a hint, as arrays have a method named "append", which is perfect for the job:

  results.append(multiplier * 6)