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

Ricardo Gonzalez
Ricardo Gonzalez
2,286 Points

Don't know what I am doing wrong.

It is telling me that the value is wrong

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

1 Answer

kirkbyo
kirkbyo
15,791 Points

The problem is with your "Learn ios" string. The challenge is case sensitive, to pass the challenge simple change your last line to:

todo.insert("Learn iOS", atIndex: 1)

If you need any more help, let me know!

Ozzie

Ricardo Gonzalez
Ricardo Gonzalez
2,286 Points

Hey kirkbyo thanks for the help but even though it still won't let me pass even though i fix what you told me to fix

kirkbyo
kirkbyo
15,791 Points

Hey, I am assuming that you are just posting all the code in the first challenge? if that's the case try adding each line individually.

Task 1

var todo = ["Learn Swift", "Build App", "Deploy App"]
todo += ["Debug App","Fix Bugs"]

Task 2

let item = todo.removeAtIndex(2)

I missed the a issue with the original question also. When removing an item from the array with the removeAtIndex method, it automatically assigns it to a variable. So when removing the item from the array it will set the value of the index passed.

Task 3

todo.insert("Learn iOS", atIndex: 1)

Let me know if that works.

Ricardo Gonzalez
Ricardo Gonzalez
2,286 Points

No i wasn't doing that but i found what my mistake was.Thanks anyways :)