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 trialJoe Blow
Courses Plus Student 229 Pointshow can i create a constant named "title" and assigned to a string named "A dance with the dragon" ?
how can i create a constant named "title" and assigned to a string named "a dance with the dragon" ?
let Title ("A dance with dragons")
2 Answers
Daniel Sattler
4,867 Pointsit´s easier then it looks ;-)
let title = "A dance with the dragon"
first you set WHAT it is... "let" is a constant value, NOT changeable once it´s been defined. "var" is a variable and can be changed and modified as many times as you like.
so we start with a let since we want a constant. now title... in programming (any language) it´s best practice to use something called "camelCasing" (you can see it hu? :-))
means the name of a variable, constant, function,... STARTS with lowercase and then continues every word upper case..
Title of movie would be "titleOfMovie"
so
let title = "A dance with the dragon"
We want that the constant "title" EQUALS "A dance with the dragon" so we write it that way ;-)
Joe Blow
Courses Plus Student 229 PointsThank you. i just started so its kinda hard :)