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 trialBrandon Sherwood
611 Pointswhat am i doing wrong?
whats wrong with my code and what is the correct why to write it?
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo += ["Debug App", "Fix Bugs"]
todo.remove[2]
let item = "Deploy App"
1 Answer
Richard Lu
20,185 PointsHey Brandon,
I'm not sure what problem you're getting, but I'll give it a shot. There seems to be two things that are wrong:
- Removing an element from a unretrievable location
- Method of removing is incorrect
To fix these issue, I've modified your code:
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo += ["Debug App", "Fix Bugs"]
todo.removeAtIndex(4) // assuming you want to modify the last position in your array
let item = "Deploy App"
I'd recommend another way of removing the last position in your array if that's what you're trying to accomplish.
todo.removeLast()
Hope I've helped. Happy Coding! :)
James Tench
43,891 PointsJames Tench
43,891 PointsWhat is the problem asking you to do?