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 Build a Simple iPhone App with Swift Getting Started with Xcode A Swift Recap

Mohammed Alsaif
Mohammed Alsaif
200 Points

How to create constant?

I have tried to create a constant as I saw in this session but I could't do it I don't know how!

getting_started.swift
var str = "Hello, bestSmartphone"
var someVariable = "aVariable"
let someConstant = bestSmartphone

1 Answer

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

Hi there! You've created at least one constant and set it equal to a variable named bestSmartphone which doesn't exist anywhere else in your code. The first step is only looking for one line of code and the constant name is supposed to be bestSmartphone with a value of "iPhone". Take a look:

let bestSmartphone = "iPhone"

This creates a constant named bestSmartphone and assigns the string "iPhone" to that constant. Hope this helps! :sparkles:

Rolando Nicomedes
Rolando Nicomedes
4,707 Points

I've actually entered that answer but I don't know why I keep getting a "Bummer! Your code could not be compiled. Please click on "Preview" to view the compiler errors." error.

Here's a screenshot