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

Eric villalobos
Eric villalobos
938 Points

what is the exact code for these two task?

s://teamtreehouse.com/library/swift-3-basics/swift-operators/working-with-operators please answer both task

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

// Task 2 - Enter your code below
Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Hi Eric,

I don't see any of your code entered here?

The Treehouse Community is a place to come for assistance, not to just be given the answers. If the answers to code challenges are just handed out, there really isn't any learning going on.
If you could post the code you are trying, then others in the Community would be able to help you sort out anything not understood and help troubleshoot where things may be going wrong.
But, without seeing any code you are trying, it's impossible for anyone to assist you.

Please share the code you are trying, and other students will be more than happy to lend a hand.

To give some hints based on the Challenge:

  • The % sign is called the modulo operator and is used to find the remainder. So, in the first task, you would need to do value % divisor operation and assign this to the constant asked for.
  • The second step is just looking for a boolean answer. This can be achieved by comparing two values to obtain a True or False using the comparator operator ==. This returned value is stored in the other constant asked for by the challenge using the assignment operator =.

With this in mind (maybe do a quick review of the videos too), give it another go. If you're still stuck, post the code you are trying and the Community will be able to offer further guidance.

:dizzy:

josh kinney
josh kinney
1,576 Points

I am stuck can someone assist?

my code:

let value = 200 let divisor = 5

let result = value % divisor

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

result == 0

let isPerfectMultiple = 0