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 2.0 Basics Swift Operators Working With Operators

Vidur Bahl
PLUS
Vidur Bahl
Courses Plus Student 1,440 Points

how to write this peace of code

how to write code for this question ?

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 remainder = value % divisor
let result = remainder 

// Task 2 - Enter your code below
let isPerfectMultiple =
Ben Masel
Ben Masel
2,004 Points

I am not sure that i can help completely because you are using pro and i am not sure if you get different code challenges to me. Your a lucky person to get pro!

3 Answers

Ben Masel
Ben Masel
2,004 Points

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

// Task 2 - Enter your code below
let isGreater = someOperation == anotherOperation (Hope this helps!)

Ben Masel
Ben Masel
2,004 Points

Hi Vidur! (Task 1) Ok let's start from scratch, Ok so this code challenge is about Boolean operations (What they mean by Boolean operations is comparing if the question is true or false) and it wants you to create a constant called "result" and make it equal "value % divisor". Next they want you to make another constant called "isPerfectMultiple" and they want it to see if "result" is an even number so you would do "let isPerfectMultiple = result == 0" The "==" tests if something equals something. So the "=" makes something equal something, and the "==" compares if a variable or constant equals something, in this code challenge 0.

Ben Masel
Ben Masel
2,004 Points

(Task 2) Firstly we want to create a constant called isGreater and make a Boolean operation to see if someOperation = anotherOperation. Instead of the assignment operator (=) we need to use the equality operator (==) to test if someOperation = anotherOperation. I will show you the complete code in my next answer!