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 trialben sasser
476 PointsIt keeps saying this code is wrong but I don't really know what I'm doing incorrectly. It worked in Xcode just fine.
// Enter your code below var arrayOfInts: [Int] = [1, 2, 3, 4, 5, 6]
arrayOfInts.append (1)
var concArray: [Int] = [5]
arrayOfInts = arrayOfInts + concArray
let value = arrayOfInts [5]
// Enter your code below
var arrayOfInts: [Int] = [1, 2, 3, 4, 5, 6]
arrayOfInts.append (1)
var concArray: [Int] = [5]
arrayOfInts = arrayOfInts + concArray
let value = arrayOfInts [5]
2 Answers
ben sasser
476 PointsYeah I figured it out right after I asked the question haha! Since the 5th value of the array would the Int [6] I just went ahead and used [5] to retrieve it... I was thinking about the array items instead of the array indexes haha! Thank you for the help! :)
Jennifer Nordell
Treehouse TeacherHey there ben sasser ! You're doing great! But take a look at that last line. It asks for the fifth value. You're putting the 6th element in the variable value. Remember, unlike humans, most computers start counting at 0. It's going to need this line.
let value = arrayOfInts[4]
Hope this helps!
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse Teacherben sasser You're welcome. And kudos on figuring it out yourself