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 Collections and Control Flow Control Flow With Conditional Statements Working With Logical Operators

Sean Lafferty
Sean Lafferty
3,029 Points

No idea how to do this. It seems like these are getting harder and the explanations in the previous videos dont

Dont go over what is necessary to complete the task! Please help!

operators.swift
var results: [Int] = []

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

     }




    // End code 
}
Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, I'm not going to leave this as an answer, but rather as a comment because I have full faith that you can figure this out! :smiley:. This concept was actually covered, but it was covered quite a while ago, so it might not be something you immediately think of. Remember, that learning to program is a little like learning math. You can't forget how to add and then suddenly be expected to be able to multiply.

Take a look at this video between about 1:35 and 2:17 and this video at around 0:58. The first one teaches about how to find if a number is even or not, and the second one is about adding items to an array. If you combine what he says in these with the things you just learned about logical operators, you should have your answer. I believe you can do this, but let me know if it’s still not making sense! :sparkles:

Sean Lafferty
Sean Lafferty
3,029 Points

Hi Jennifer! thankyou for the response however the videos that you have linked I cannot seem to open! I cant seem to find them even if i search for them!

1 Answer

Kayondo Martin
Kayondo Martin
7,481 Points

Hi, I think you need either to write the function "not even" or hardcode, like

if( n%2 != 0) //for an odd number n
{
//do something
}
// and 
if (n%7 == 0)// for a n being a multiple of 7
{
///code
}

After that, you can append to the array as asked