Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Basics (retired) Collections Modifying an Array

Error in the quiz answer

The 2nd quiz question for "Modifying Arrays" asks for removing the 3rd entry in my code I am putting atIndex value equal to 2 (since arrays start from 0) but inbuilt answer is rejecting 2 instead accepting 1 as true value which is wrong since question asks for removing the 3rd entry while the answer is implying removing 2nd value. Kindly look into this

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

2 Answers

Chris Shaw
Chris Shaw
26,662 Points

Hi Nikhil,

The reason the challenge isn't accepting your answer is because you're removing the third item in the array which is "Deploy App" then removing "Debug App", the challenge asks for you to remove the third item and assign it as a value to a new constant called item which you're doing but after removing it. Simply removing the first removeAtIndex declaration will solve the problem and the challenge will pass.

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

Happy coding!

Hi I just did this and realise my mistake but 3rd quiz question which is "Learn iOS" and assigning it 2nd position in the todo that still is not resolving as it shows the bummer your todo has wrong value