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 trial

iOS Swift Basics An Introduction to Swift Programming Working With Constants

Abotsi Godwin
PLUS
Abotsi Godwin
Courses Plus Student 1,400 Points

Somone should help me with a constant Quiz, right now.

It says to create a constant name favoriteDessert and assigned it to a strong favorite dessert.

constants.swift
// Enter your code below
let = "favoriteDessert"

2 Answers

Andrew Kyu
Andrew Kyu
5,842 Points

Right now your constant doesn't have a name to it. What the question is asking you to do is name your constant 'favoriteDessert' and assigning your favorite dessert as its value. For example the correct syntax for this is:

let favoriteDessert = "Ice cream"

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi, Andrew! I took the liberty of changing your comment to an answer to allow for voting and possible selection of "Best Answer". Thanks for helping out in the Community! :sparkles:

Abotsi Godwin
Abotsi Godwin
Courses Plus Student 1,400 Points

Thanks, a lot Andrew. That was really simple and understandable.

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! To create a constant you use the let keyword, and that part you did just fine. The name of the constant should follow the the let keyword. Then there should be an equals sign and on the right side of the equals sign should be the value that you want to assign to it.

This is how I did it:

let favoriteDessert = "chocolate cake"

Here I define a constant named favoriteDessert and I assign the string "chocolate cake" to this constant. But you may, of course, assign your own string for your favorite dessert.

Hope this helps! :sparkles: