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 trialMaka Haidara
442 PointsI m having serious difficulties with that exercice. What is the correct answer ?
The challenge task 2of 2, i really don't get it. That s my answer i don' t where is my mistake let currencies = [ "US": "Dollar", "UK": "Pound", "JP": "Yen" ] let ukCurrency = [ "UK": "Pound" ]
let currencies = [ "US": "Dollar", "UK": "Pound", "JP": "Yen" ]
let ukCurrency = [ "UK": "Pound" ]
2 Answers
Jhoan Arango
14,575 PointsHello Maka:
Very good.. You almost got it, but here is how you want to do this
let ukCurrency = currencies["UK"]
kjvswift93
13,515 PointsThe seconds part of the challenge is worded in a somewhat difficult to discern way, but if you read carefully the challenge can be translated as "Create a new constant and name it ukCurrency, then give it the value "Pound".
let ukCurrency = "Pound"
Jhoan Arango
14,575 PointsHi Kyle:
Not that I want to contradict your answer. The challenge says Assign the value for key "UK" to a constant named ukCurrency.
This will be assigning
let ukCurrency = currencies["UK"]
// If you call ukCurrency youβll see its value which is βPound"
What you are doing is declaring a constant name ukCurrency, and giving it the value of βPoundβ. The compiler takes this as the right answer and allows the challenge to be passed, but itβs not the answer they are looking for. Because this is declaring a constant, something that was shown in the first parts of swift basics. This challenge is about capturing a value from a dictionary.