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 Basics (retired) Collections Modifying an Array

Lia Gaetano
Lia Gaetano
2,619 Points

Append array

I cannot figure out the correct answer/syntax for this question to append "Debug App", and "Fix Bugs" to the list var todo.

2 Answers

Jhoan Arango
Jhoan Arango
14,575 Points

Hello Lia :

To be able to add an item to an array there are a few ways.

// Empty array
var someArray: String = []

// Using the append method, this will only allow you to add one item at a time.

//  Using the addition assignment operator. 
// This way, you can add more than one item.

someArray += ["Item", "Item2"]

Good luck

Lia Gaetano
Lia Gaetano
2,619 Points

Ah! Thanks! I was trying to add two items to append.