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 2.0 Collections and Control Flow Introduction to Collections Working with Arrays

Jeremy Stewart
Jeremy Stewart
1,545 Points

Don't understand quiz answer

The quiz question asks me to assign a constant and retrieve the 5th number from the array. The code i've entered does this. What am I doing wrong?

arrays.swift
// Enter your code below

var arrayOfInts = [100,200,300,400,500,600]

arrayOfInts.append(700)

arrayOfInts += [800]

let numberFive = arrayOfInts[4]

3 Answers

Alexander Smith
Alexander Smith
10,476 Points

where you have

let numberFive = arrayOfInts[4]

they just wanted it to be named value. Everything else is correct

Sidney Swenson
Sidney Swenson
2,429 Points

Correct code would just be

let value = arrayOfInts[4]

Jeremy Stewart
Jeremy Stewart
1,545 Points

ok thx.

it would be so helpful if you could reveal answers on quizzes. It really stops the learning when the question / answer subtleties are so minimal.