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 trialDavid Gieseke
1,662 PointsI keep getting the same message on this Challenge: "You need to call the 'Insert' method on the array." Nothing works?
Challenge: Insert a new item "Learn iOS" at the second position in the todo array.
Keeps saying I need to call the 'insert' method on the array. I try:
todo.insert("Learn iOS", atIndex: 2) I've done various number and syntax combinations. It doesn't seem to like them? Seems ok in the play ground.
var todo = ["Learn Swift","Build App","Deploy App"]
todo.append("Debug App")
todo.append("Fix Bugs")
todo.removeAtIndex(1)
let item = todo.removeAtIndex(1)
todo.insert("Learn iOS",2)
2 Answers
Alain Ghiai
4,287 Pointsvar todo = ["Learn Swift", "Build App", "Deploy App"]
todo.append("Debug App")
todo.append("Fix Bugs")
let item = todo.removeAtIndex(2)
todo.insert("Learn iOS", atIndex: 1)
Try this
Jhoan Arango
14,575 PointsHello David:
SO close, the only thing is that the second position has an index of 1. But you are doing a great job.
Remember, that arrays have indexes starting from 0. Meaning the first position will always be 0.
Good luck.
David Gieseke
1,662 PointsThanks guys!
I finally got it to run. I really appreciate the help!!!!
Jhoan Arango
14,575 PointsJhoan Arango
14,575 PointsHello Alain:
I've modified your code so that it can be properly displayed. Didn't change anything in your answer.
Good answer !