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 trial

iOS Swift Basics (retired) Collections Modifying an Array

Joe Nelson
Joe Nelson
284 Points

Why does it say my todo var has wrong value?

Says "your 'todo' variable has wrong value in it"?

arrays.swift
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo += ["Debug App","Fix Bugs","Learn iOS"]
todo.removeAtIndex(1)
let item = todo.removeAtIndex(1)
todo.insert("Learn iOS", atIndex: 1)
Joe Nelson
Joe Nelson
284 Points

**** "Learn iOS" is not supposed to be in the second line

1 Answer

Chase Marchione
Chase Marchione
155,055 Points

Hi Joe,

1) Looks like you're appending "Learn iOS" twice. When you do your insert in the third part of the challenge, that is the only time you'll need to append it--no need to hard code it in your first statement, adding an extra string.

2) You have two removeAtIndex function calls, and you're currently removing the second string. We want to remove the third string.

var todo = ["Learn Swift", "Build App", "Deploy App"]
todo += ["Debug App","Fix Bugs"]
let item = todo.removeAtIndex(2)
todo.insert("Learn iOS", atIndex: 1)

Hope this helps!

Joe Nelson
Joe Nelson
284 Points

Hey CJ,

Thank you for the answer! I think there may be a bug with that challenge because it would not let me move on from task two with

let item = todo.removeAtIndex(2)

Thank you for your help!