Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Basics Swift Operators Working With Operators

JUAN BORRAS
JUAN BORRAS
716 Points

Assign the Boolean result of the comparison

Why not a right answer?.
anotherOperation is bigger

operators.swift
// Enter your code below
let value = 200
let divisor = 5

let someOperation = 20 + 400 % 10 / 2 - 15
let anotherOperation = 52 * 27 % 200 / 2 + 5

// Task 1 - Enter your code below
let result = value % divisor    

// Task 2 - Enter your code below
let isPerfectMultiple = result == 0


let isGreater = anotherOperation > someOperation

3 Answers

andren
andren
28,558 Points

The challenge asks you to write code that checks if someOperation is greater than anotherOperation. Your code checks if anotherOperation is greater than someOperation, which is the exact opposite.

The fact that anotherOperation is the bigger one is irrelevant to this task, as it does not affect how the code should be written.

The code for task two should look like this:

let isGreater = someOperation > anotherOperation
JUAN BORRAS
JUAN BORRAS
716 Points

Typed on challenge and didnยดt go through

andren
andren
28,558 Points

It should work, I tested it before I posted it.

Challenges can sometimes get a bit buggy though, try restarting the challenge and paste this code in:

// Enter your code below
let value = 200
let divisor = 5

let someOperation = 20 + 400 % 10 / 2 - 15
let anotherOperation = 52 * 27 % 200 / 2 + 5

// Task 1 - Enter your code below
let result = value % divisor    

// Task 2 - Enter your code below
let isPerfectMultiple = result == 0


let isGreater = someOperation > anotherOperation

And you should be able to pass both tasks.

JUAN BORRAS
JUAN BORRAS
716 Points

Deleted and restarted challenge but nop didnยดt work