Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

2 Answers

Steven Deutsch
Steven Deutsch
21,046 Points

Hey Jomar Martinez,

Always post some code even if you know what you're posting is wrong and horrible! I'll help you with this one this time though. The challenge asks us:

Challenge Task 1 of 1:

var results: [Int] = []

for n in 1...100 {
    // Enter your code below

// The for loop iterates over the range of numbers 1...100 and assigns each to the constant n
// We then need to create an if statement and perform two checks (operations) on the constant n
 // The first check is if the number is odd (n % 2 != 0)
     // If the remainder of n divided by 2 is not equal to 0, the number must be odd
// the second check is if the number is a multiple of 7 (n % 7 == 0)
    // If the remainder of n divided by 7 is equal to 0, the number must be a multiple of 7
// We use the AND operator && to specify that BOTH of these conditions must be true

    if (n % 2 != 0) && (n % 7 == 0) {
     // If both are true, we use the append() method to add the value of n to the results array

    // End code 

Good Luck!

Jomar Martinez
Jomar Martinez
Courses Plus Student 2,003 Points

Thank you sooo much! next time i will post the code. Thanks again for the help Steven Deutsch!