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 Zakaryan
512 PointsWhere is my mistake
I don't see my mistake here... also all the other steps were correct, why is this one wrong???
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", atIndex: 3)
1 Answer
krilnon
1,458 PointsThe task wants you to insert the new string at the second position in the array. Because Swift uses 0-based indexing, you're adding it at the fourth position (0 is first, 1 is second, 2 is third, 3 is fourth). So you should use atIndex: 1
.
Also, I noticed that you've removed two items from the list in previous step. That's different than what I did, which was to remove one item at index 2. That might also be causing problems with the grading.
David Zakaryan
512 PointsDavid Zakaryan
512 PointsThanks :D