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 trialJeremy Turner
1,567 PointsAssign the value for key "UK" to a constant named ukCurrency. Could someone provide the answer and explain it? Thanks!
1 let currencies = [ "US": "Dollar", "UK": "Pound", "JP": "Y ]
8 Answers
Logan R
22,989 PointsIt is pretty easy to get the object associated with the key. Do:
Array["key"]
So in this case:
let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"]
let ukCurrency = currencies["UK"]
adensaid
4,461 Pointsi had the same question from the challenge question. I got confused on the optional intro from the dic lecture. thnx a lot guys.
Jeremy Turner
1,567 PointsGlad to know I'm not alone Lol
McKenna Rowe
2,930 PointsI'm stuck on this quiz question. My code was exactly as you have above, but I keep getting an error "Your code could not be compiled. Please click on "Preview" to view the compiler errors.". the errors don't load?
McKenna Rowe
2,930 Pointsso I had to reload the lesson a few times before it let me pass. weird.
Desiree Welch
742 PointsI find myself thinking way too hard re: questions!
I thought we needed to remove the key first and then assign it a value. So just to be clear on the conceptualization, the reason why we don't do this is simply because the key/items in the array are not variables?
Logan R
22,989 PointsIn this case, it is not removed because you may want to use the same value again later in the program.
Igors Devels
1,272 Pointsough, thank you for the help. Easier than i thought.
Rodolfo Urbina
3,705 PointsHad the same question. Thanks!
Darren Whyte
3,973 PointsMe too! I was stuck for a minute lol. Thanks!
Jeremy Turner
1,567 PointsJeremy Turner
1,567 PointsThanks Logan. It was super easy. I was embarrassed to even ask. lol
Logan R
22,989 PointsLogan R
22,989 PointsDon't be embarrassed :) Everyone, even myself, have to ask questions to learn. If you ever have any more questions, feel free to post them on the forums!