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 trialMathias Bakken
3,167 PointsUsing array subscripting, retrieve the string "bread" from the array and assign it to a variable named cart. Help!
I attempted to removeAtIndex() and I looked up documentation on subscripting. I made it work in both instances in my own playground, but I can't seem to move forward with the work on treehouse. Please Help!
var shoppingList = ["toothpaste", "bread", "eggs"]
if shoppingList.count > 0 {
var cart = shoppingList[1]
}
1 Answer
Steve Hunter
57,712 PointsHi Matthias,
You're doing fine. There's no need for the conditional test.
var cart = shoppingList[1]
That should be fine!
Steve.
Gabe Nadel
Treehouse Guest TeacherGabe Nadel
Treehouse Guest TeacherSteve is right, you don't need the test to pass the code challenge, in fact putting that in there is why it's getting rejected. That said, it's good practice to checks of that flavor in the "real world".