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 trialjohnbair
512 PointsPlease remove the third item ("Deploy App") and assign it to a constant named item.
I was able to remove the third item todo.removeAtIndex(2) but not sure what is meant by ...and assign it to a constant named Item..
this is my thought process..?
let todo(2) = item
thoughts????
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo.append ("Debug App")
todo.append ("Fix Bugs")
todo.removeAtIndex(2)
2 Answers
johnbair
512 PointsI figured it out. Finished the section...
let item = "Deploy App" todo.insert("Learn iOS", atIndex: 1)
Paul O'Sullivan
1,457 PointsHi,
Use removeAtIndex and assign the item being removed as a constant that you declare as "item".
So from your example ....
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo.append ("Debug App")
todo.append ("Fix Bugs")
//remove 3rd in array and assign as constant "item"
let item = todo.removeAtIndex(2)
//check value of item
item
johnbair
512 PointsThanks Paul