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 trialPablo Caro
4,191 PointsCan't get pass Step 1
Hello friends! why is this wrong?
let numbers = [Int](0...50)
// Enter your code below
func isOdd (number: Int) -> Bool {
if number % 2 == 0 { return true }
else { return false }
2 Answers
Michael Reining
10,101 PointsHi Pablo,
You are so close! Just reverse the logic.
number % 2 == 0 // this means the number is even
The final code looks like this
let numbers = [Int](0...50)
// Enter your code below
func isOdd(number: Int) -> Bool {
if number % 2 == 0 {
return false
} else {
return true
}
}
I hope that helps,
Mike
PS: Thanks to the awesome resources on Team Treehouse, I launched my first app.
Now you can practice writing Swift code directly on your iPhone :-)
Pablo Caro
4,191 PointsThanks Mike and congrats on the App! looks great!