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

Christopher J Doyle
Christopher J Doyle
682 Points

What am i missing? Please help

What am I missing? Is the append method wrong/

for multiplier in 1...10 { results.append(multiplier * 6) }

var results: [Int] = [multiplier]

loops.swift
// Enter your code below

for multiplier in 1...10 {
  results.append(multiplier * 6)
}


var results: [Int] = [multiplier]

1 Answer

Magnus Hållberg
Magnus Hållberg
16,953 Points

Its all correct except that you try to append to an array that is, at the time of appending, not declared. Move the loop after the array declaration.

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

for multiplier in 1...10 {
  results.append(multiplier * 6)
}