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 trialChristian Kroul
9,849 PointsFor in loops swift task 2 of 2
This is the error
Your array needs to contain the first 10 multiples. Make sure your range goes from 1 to 10
// Enter your code below
var results: [Int] = []
for multiplier in 1...10 {
print("\(multiplier) times 6 is equal to \(multiplier * 6)")
}
But its correct please tell me what i did wrong
4 Answers
ianhan3
4,263 PointsOh for step 2 it asks you to append to the results array. Your print statement is valid but the question is asking something more in the second step. Here's a walkthrough of the whole problem I did yesterday:
- Create a for in loop that iterates over a range from 1 to 10. Name the temporary constant "multiplier".
for multiplier in 1...10 {
}
- Use multiplication to get the multiples of 6 from the loop
for multiplier in 1...10 {
multiplier * 6
}
- Append it to the given array "results"
for multiplier in 1...10 {
results.append(multiplier * 6)
}
ianhan3
4,263 PointsYour code will work for step 1. I just tested it in the challenge and it went through!
Christian Kroul
9,849 PointsYes thank you Ian Han
but step 2 has this error
Your array needs to contain the first 10 multiples. Make sure your range goes from 1 to 10
i guess it can be treehouse's code check thingy
Christian Kroul
9,849 Pointsoh ok, looks like i did not notice the directions. Thank you very much
Brian Patterson
19,588 PointsBrian Patterson
19,588 PointsI am finding this has not been very well explained. I can understand it as well.