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

Veronise Umutoni
Veronise Umutoni
512 Points

I am having trouble inserting an item (Learn iOS)in the todo array.

The code is working in my computer playground but when i try to learn it in the challenge test it is return an error.

Thank you for you help.

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

4 Answers

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

you are removing "build App" and in challenge we have to remove "deploy App"

yu welcome :)

I m having trouble answering this, I dont understand why is this wrong, someone help?

var todo = ["Learn Swift", "Build App", "Deploy App"]

todo.append("Debug App")

todo.append("Fix Bugs")

todo.removeAtIndex(1)

let item = todo.removeAtIndex(1)

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

It says "Your todo variable has the wrong value in it"

Please Help!

var todo = ["Learn Swift", "Build App", "Deploy App"]

todo.append("Debug App")

todo.append("Fix Bugs")

let item = todo.removeAtIndex(2)

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

yu re removing wrong value