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 trialHans Lohmann
414 PointsHelp: iOS swift development basic/ types; numbers and booleans.
We need store some information about a book in several variables. Let's start with the title of book. Create a constant named title and assign it a string: "A Dance with Dragons".???
Jeff Wilkey
10,296 PointsI'm with Jayden on this one, you should really just skim over the video again. Except be sure that your constant is named title
as the instructions state.
Hans Lohmann
414 PointsI appreciate the help. I think the biggest problem I have right now is interpreting what the question is asking me to do. I plan to look over this problem again shortly, hopefully your guidance will be helpful. Thanks
1 Answer
Jhoan Arango
14,575 PointsHello Hans :
Assigning values to a constant or variable is simple. Think of it as STORING something inside a word, or giving that word a meaning. The first thing the challenge is asking for is:
"We need store some information about a book in several variables. Let's start with the title of book. Create a constant named title and assign it a string: "A Dance with Dragons".???”
You know that a constant starts with the word let, after this you want to give a name to the constant
let name
In order to give a value to your constant you have to use the equal sign “ = “.
let name =
// the equal sign assigns values
Now, after creating a constant, you must give it ITS value. In this case it will be a STRING
let name = “This will be the value”
I hope this helps you solve your challenge. Now you can go back and give it a try.
Carlos Rubio
497 PointsI'm at the same place in that track. I have rewatched the video. I'm doing exactly what you're saying, I even try it in Xcode and it works. But when I put it on the assignment itself, it comes back wrong (if I click "preview" instead nothings comes up, it's just a blank page).
Jhoan Arango
14,575 PointsCarlos, what is the answer you are giving it ?
Carlos Rubio
497 Pointslet tittle = "A Dance with Dragons"
(I also try with: let tittle: String = "A Dance with Dragons" even though that seemed redundant)
Jhoan Arango
14,575 PointsCarlos, I think I have seen where you have your error.. When they ask for a challenge, they are very strict with spelling and case sensitive.
let title = “A Dance with Dragons”
the problem is “title” instead of “tittle”
Carlos Rubio
497 Pointsso my mistake was not on the "swift" language but on the "english" language... fair enough.. lol!
Thank you Jhoan!
Jayden Spring
8,625 PointsJayden Spring
8,625 PointsCouldn't be a more simple question. Break it down and you should understand it - the example wants you to store the title of a book by:
If you cannot complete the code challenge, I suggest you re watch the video or read the swift programming guide. I feel it is more beneficial for you to solve this yourself rather than me post an answer.