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 trialDrew Scolaro
Courses Plus Student 855 Pointshow is this the second line of code not right, I tried it in Xcode and it printed 3
help
var todo: [String] = ["Learn Swift", "Build App", "Deploy App"]
println(3)
2 Answers
Faisal Alsheikh
8,841 PointsTry this:
Println(todo[2])
Note that your array has 3 strings, ur first string is indexed at 0 then 1 then 2
Println(3) is only printing out the Int 3 into the console...
J.D. Sandifer
18,813 PointsIt looks like you're doing the "print the number of items in the array" challenge - is that right?
If so, the problem is that I believe that the challenge looks to see that you're correctly doing the challenge, not just that you get the right answer.
In other words, even though "3" is the correct answer, you're not getting it the correct way.
Here is my suggestion to fix your code - note the comment below:
var todo: [String] = ["Learn Swift", "Build App", "Deploy App"]
println(todo.count) // this prints out a 3 because there are 3 items in the array