iOS Swift Collections and Control Flow Control Flow With Conditional Statements Working With Logical Operators

Shawn Tsou
PRO
Shawn Tsou
Pro Student 2,281 Points

There's a bug in results checking Following is my code and I believe it's correct

for n in 1...100 { // Enter your code below if ((n % 2 != 0) && (n%7==0)){ results += [n] } // End code }

operators.swift
var results: [Int] = []

for n in 1...100 {
    // Enter your code below
    if (n % 2 != 0) && (n%7==0){
        results.append(n)
    }
    // End code
}

1 Answer

Magnus Hållberg
Magnus Hållberg
16,951 Points

You just need a space before and after the equals operator, it’s picky that way.

    if (n % 2 != 0) && (n%7 == 0){
        results.append(n)
    }