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 trialYale Wang
1,015 PointsSwift array Question
We are at the grocery store and we picked up the bread. Using array subscripting, retrieve the string "bread" from the array and assign it to a variable named cart.
this is my code. i keep getting "Bummer" is my code wrong?
var shoppingList : [String] = ["toothpaste", "bread", "eggs"] var cart = shoppingList.removeAtIndex =(1)
We are at the grocery store and we picked up the bread. Using array subscripting, retrieve the string "bread" from the array and assign it to a variable named cart.
var shoppingList : [String] = ["toothpaste", "bread", "eggs"]
var cart = shoppingList.removeAtIndex =(1)
1 Answer
Vrund Patel
11,994 PointsChallenge is asking to assign the variable cart to bread. Therefore, bread is at index 1 in the array.
var cart = shoppingList[1]
Hope this helps!