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

what am i doing wrong with my syntax?

what can i correct on my syntax?

arrays.swift
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo.append ("Debug App", "Fix Bugs")

3 Answers

Jhoan Arango
Jhoan Arango
14,575 Points

Hello Brandon :

You are doing well. One detail that I am not 100% sure they explained it in the video is that the append() method, only adds ONE item at a time, and this item goes into the end of the array.

But thankfully there are other ways to add 1 or more items at the same time.

If you want to pass this challenge you can do the following codes.

// First solution

var todo = ["Learn Swift", "Build App", "Deploy App"]
todo.append ("Debug App")
todo.append("Fix Bugs")

// Second solution is to use the addition assignment operator +=

todo += ["Debug App","Fix Bugs"]

Hopefully this helps you a bit

Good luck and Happy Coding

Steven Deutsch
Steven Deutsch
21,046 Points

Hey Jhoan,

I love that second solution! Good to know.

Thanks!

Raymond Yeh
Raymond Yeh
2,965 Points

Try ending semi colons to the end of every line.

Steven Deutsch
Steven Deutsch
21,046 Points

Hey Brandon Sherwood,

I think you have to append each individually. I think this is because append only accepts one parameter, but I'm still learning myself!

var todo = ["Learn Swift", "Build App", "Deploy App"]
todo.append("Debug App")
todo.append("Fix Bugs")

Let me know if this helps. Good luck!