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 trialJomar Martinez
Courses Plus Student 2,003 PointsI don't know how to solve this challenge
How can i solve this?
2 Answers
Steven Deutsch
21,046 PointsHey 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
results.append(n)
}
// End code
}
Good Luck!
Jomar Martinez
Courses Plus Student 2,003 PointsThank you sooo much! next time i will post the code. Thanks again for the help Steven Deutsch!