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

how do i add two value to an array by concatenation using the append method?

??

array.swift
// Enter your code below
var arrayOfInts = [0,1,2,3,4,5]

arrayOfInts.append [0,1,2,3,4,5] + [6,7]

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey James,

I feel you may be misinterpreting the instructions.
There are two parts to the second task, and each part is individual in itself. The first part wants you to use append() to add a value and the second part wants you to use concatenation to add another value, so the answer will be two lines of code like so:

arrayOfInts.append(6)
arrayOfInts += [8]

It may be a good idea to have a quick review of Adding Items to Arrays before moving on.

Keep Coding! :) :dizzy:

thank you

i typed everything in like you said and it worked, but i dont understand why the bottom is 8 lol?

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

The 8 is just the value I chose to add to the array. If I knew how to count, I would have used 7 Lol :see_no_evil:.
:)
So, it could have be anything really...