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 trialRJ Pappas
442 PointsChallenge Task 3 of 3 is telling me my 'todo' variable has the wrong index#. i believe it should be 1. Tried all#'s
see above
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:1)
1 Answer
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsOn line 4 you're removing "Build App" at index 1. It didn't want you to do that. On line 5, you did correctly remove "Deploy App" as they asked, but if we backtrack and take away the code you had on line 4, this means when you're removing "Deploy App" you will be removing it from index 2 instead of index 1 now.
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo.append("Debug App")
todo.append("Fix Bugs")
// Remove this line of code you had here
let item = todo.removeAtIndex(2) // This index is now 2 instead of 1, because of the change we just made above
todo.insert("Learn iOS",atIndex:1)