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

Caden Nichols
Caden Nichols
389 Points

Swift Collections and Control Flow Challenge Task help

When I complete Task #1 it says it's fine, but when I complete task 2 is says that Task #1 is no longer passing. I do not have this problem when I put it into playground so I am confused. Did I do anything in task 2 to make task 1 not work??

Here are the instructions: " Since the array is mutable, let's add two more values to the existing array. There are two ways we can add items to an array and I want you to give both a try. First, add one item to the array using the append method.

Remember: We invoke methods on an array using a period or dot. After the dot we write out the method name and a value to append in parentheses following the name.

Next, add another item to the array by concatenating an array. When concatenating, assign the results of the expression back to arrayOfInts."

// Enter your code below
var arrayOfInts: [Int] = [1,2,3,4,5,6]
arrayOfInts = arrayOfInts + [8,9,]

1 Answer

It turns out that you just ONLY needed to add 2 numbers.

// Enter your code below
var arrayOfInts = [1,3,5,7,9,11]
arrayOfInts = arrayOfInts + [15]

But you were mostly right.