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 trialJonathan Drulard
Courses Plus Student 541 PointsFinally, we forgot to add that we need to learn iOS development prior to building an app. Insert a new item titled "Lear
Finally, we forgot to add that we need to learn iOS development prior to building an app. Insert a new item titled "Learn iOS" at the second position in the todo array.
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo += ["Debug App", "Fix Bugs"]
let item = todo.removeAtIndex(2)
todo.insert("Learn IOS", atIndex: 2)
2 Answers
Nisarg Rajvi
Courses Plus Student 733 Pointshey that problem said " add at second position"
so for that it will be
todo.insert("Learn IOS", atIndex: 1)
it worked for me!
Nick Kohrn
36,936 PointsJonathan,
Remember that arrays begin with a base index of 0. So, if you have 5 items in your array, your indexes are 0-4. If you have 10 items in the array, the indexes are 0-9.
With that being said, when you call todo.insert("Learn iOS", atIndex: 2)
, you are actually inserting the string as the third item in the array.
Just change your index to 1
to insert the string into the second index of the array.
Hope this helps!
Garrett Bauer
3,318 PointsNick, this didn't help. Please just give me the answer. I've tried everything.
Nick Kohrn
36,936 PointsGarrett,
Can you post the code that you have tried?