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 trialIbrahim Abdul-Karim
Courses Plus Student 296 PointsArray Challenge 3/3
I can't figure out why this is wrong it says the value in my todo variable is wrong. It asks me to insert "Learn iOS" in the second position of the array.
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo += ["Debug App","Fix Bugs"]
todo.removeAtIndex(1)
let item = todo.removeAtIndex(1)
todo.insert("Learn iOS", atIndex: 3)
1 Answer
Chris Shaw
26,676 PointsYou have a couple of problems which I've mentioned below.
- Your first called to
removeAtIndex
isn't needed as you're not assigning the value to anything - Your second call to
removeAtIndex
should have a value of 2 as you need to remove the 3rd array value - Your
insert
call should add the Learn iOS string at index 1 which is the second item in the array
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo += ["Debug App","Fix Bugs"]
let item = todo.removeAtIndex(2)
todo.insert("Learn iOS", atIndex: 1)
Happy coding!
Ibrahim Abdul-Karim
Courses Plus Student 296 PointsIbrahim Abdul-Karim
Courses Plus Student 296 PointsThank you for your help it's greatly appreciated!