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 Collections and Control Flow Introduction to Collections Working With Arrays

Paolo Di Donato
Paolo Di Donato
4,945 Points

Error caused in challenge 2 of 4 from code in challenge 1 of 4.. after passing challenge 1 with no problems..

I have passed step 1 in collections and control flow - when I am doing the testing I seem to challenge task 1 with no problems but when I go to submit challenge 2 of 4 I get an error the there is something wrong in step 1.. So I go back to challenge 1, resubmit and go to challenge 2 and the same thing continues to happen..

Is there a problem on treehouses end? I put the code into playground and there are no issues with it.

var arrayOfInts: [Int] = [0,1,2,3,4,5]

arrayOfInts.append(6)

arrayOfInts.append(7)

arrayOfInts += [8,9]

array.swift
// Enter your code below

var arrayOfInts = [0, 1, 2, 3, 4, 5]

1 Answer

So the question is actually asking you to add a single item via the append method and a single item via concatenation

There isn't an issue with your code or treehouse, just with what the questions is asking.

So per your code:

var arrayOfInts: [Int] = [0,1,2,3,4,5]

arrayOfInts.append(6)

arrayOfInts.append(7) // This line is not needed

arrayOfInts += [8,9] // You should only concat a single value such as [8]

Give that a try.