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 trial

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."

array.swift
// Enter your code below
var arrayOfInts: [Int] = [1,2,3,4,5,6]
arrayOfInts.append(7)
arrayOfInts = arrayOfInts + [8,9,]

1 Answer

Edwin Rivera
seal-mask
.a{fill-rule:evenodd;}techdegree
Edwin Rivera
Data Analysis Techdegree Student 4,895 Points

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.append(13)
arrayOfInts = arrayOfInts + [15]

But you were mostly right.