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 trialLukes Ivi
2,001 PointsI am trying to get past this Challenge Task in the Changing Arrays section. My code is not working
Hi,
I am trying to get past the Challenge task for changing arrays.
It is asking me to insert "Learn iOS" as a new item and add it to the 2nd position in the array.
My code is:
//
todo.insert("Learn iOS", atIndex: 1)
//
It is not letting me pass...
PLEASE HELP!
Thanks a lot.
4 Answers
Lucas Passarella
4,885 PointsCan you show us more of your code?
Is todo assigned as a constant (let) or a variable (var)
It won't let you insert or append or delete if it's a constant
Allie O.
11,601 PointsAre you building up your code on top of task 1 and 2? If you remove your code from previous tasks, then Task 3 no longer passes in that challenge.
Juan Francisco Andrade Álvarez
23,997 PointsHi, This code, at the end of the challenge should work:
var todo = ["Learn Swift", "Build App", "Deploy App"] todo = todo + ["Debug App","Fix Bugs"] let item = todo.removeAtIndex(2) todo.insert("Learn iOS", atIndex: 1)
Good Luck!
Lukes Ivi
2,001 PointsThanks guys. I redid the exercise and it worked. I must have deleted some code from the previous excursus.
Thanks a lot!