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 trialBoris Davidovic
1,010 PointsarrayOfInts
can someone help me out with arrayOfInts problem? i would like to know the solution to this one and explained please.
// Enter your code below
var arrayOfInts = [1,2,3,4,5,6]
arrayOfInts.append(7)
arrayOfInts += [8]
arrayOfInts.remove(at: 4)
let value = 5
2 Answers
Boris Davidovic
1,010 Pointssolved it after 2 mins and reading the problem again.
RESULT :
var arrayOfInts = [1,2,3,4,5,6] arrayOfInts.append(7) arrayOfInts += [8] arrayOfInts [4] = 5 let value = 5
thanks ! good luck !
andren
28,558 PointsThe solution for task 3 is as follows:
let value = arrayOfInts[4] // You retrieve a value by passing in the index you want to retrieve within brackets
The task did not ask you to remove anything at index 4, but to retrieve it. The easiest way to retrieve a value from an array is by using bracket notation where you simply pass the index you want to retrieve within brackets following the name of the array.
Do note that this is only the solution to task 3, not to the entire challenge.