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.
Assigning results to a constant named value in Swift
Hi! I'm stuk on this challgenge:
Challenge Task 3 of 4
We also learned about reading values from an array. Retrieve the 5th item (remember array indexes start at 0) and assign the result to a constant named value.
My code is:
var arrayOfInts = [1,2,3,4,5,6]
arrayOfInts.append(7) arrayOfInts += 
arrayOfInts = "constant"
Michael Reining10,101 Points
The problem is in your last line of code.
The challenge asks you to create a new constant called "value" and assign the 5th item of the array to the new constant.
// Enter your code below var arrayOfInts = [0,1,2,3,4,5] arrayOfInts.append(6) arrayOfInts +=  // Let's break it down // Create new constant called "value" // Set it's value to the 5th item of the integer array let value = arrayOfInts
I hope that helps,
PS: Thanks to the awesome resources on Team Treehouse, I just launched my first app. :-)
sometimes this stuff really confuses me! this really is getting frustrating spending 30 mins trying to figure it out! thanks for the solution
let value = arrayOfInts
First I had: arrayOfInts let value = arrayOfInts I wrote this code because I thought that I had to show where/how I retrieved the 5th item. So I was stuck on this for ages unless I took out my first line and left the second.