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 trialTOCHI ORAJIAKU
Courses Plus Student 1,592 Pointsnot sure what is wrong with my code
dont know to append the array when I get a value
// Enter your code below
var results: [Int] = [1,2,3,4,5,6,7,8,9,10]
for multiplier in 1...10
{
results.append("\(multiplier * 6)")
}
4 Answers
Anthony Lafont
17,075 PointsOK, I made a mistake, you don't have to put data in the array declaration, and leave it as an empty array.
Here is what you should do:
var results: [Int] = []
for multiplier in 1...10 {
results.append(multiplier*6)
}
Anthony Lafont
17,075 PointsHi Tochi,
In the challenge, the variable results is an array of Ints. By appending it with the quotation marks, you're telling the compiler that the data you're appending are Strings, and that's why you get an error. To pass the challenge, you just have to give up the quotation marks
var results: [Int] = [1,2,3,4,5,6,7,8,9,10]
for multiplier in 1...10 {
results.append(multiplier*6)
}
Anthony
TOCHI ORAJIAKU
Courses Plus Student 1,592 PointsHi Anthony, thanks for the reply. I am getting another error now which says 'Make sure the results array constains the first multiple of 6' . I'm not exactly sure why I am getting this
TOCHI ORAJIAKU
Courses Plus Student 1,592 Pointsokay it worked. Thanks for your help