Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Basics Swift Types String Manipulation

I've declared let name = "Courtney" but on the next line am I meant to let greeting = "Hey, there" ?

and then do I make it interpolated?

// Enter your code below
let name = "Courtney"
let greeting = "\"Hey There,", (name)"

4 Answers

First, you only need one string. Second, I don't see why the \ is way in the front of the string. Huh? You heard, you need the \ in front of the (), not in front of the string!

Third, your string in general isn't the string the challenge wanted. The challenge wanted something like "Hi there, Courtney" but your string returns "Hey There, Courtney". Code challenges are very picky and will cause a Bummer! message if you don't do exactly what it says.

Anyway, this is the correct string that you should assign to greeting:

"Hi there, \(name)"
Jiri Janecek
Jiri Janecek
6,443 Points

You're almost there. First, you have way too many " there. You need just 2: "The left one starts the string and the right one ends it".

Now, if you want to add a variable/constant to an string, you do it like this: (nameOfVariable)

For example, if you have a constant named color with value "red" and you write such code "My favorite color is (color)", it will print out this: My favorite color is red

Tyler Dotson
Tyler Dotson
Courses Plus Student 1,740 Points

Alecander Davison, how do you had code into your comment

Read the markdown cheatsheet.

It is below the answer box.

Scroll to the bottom of the page and look beneath the answer box.

If you want to learn more about the markdown cheatsheet, look here

Tyler Dotson
Tyler Dotson
Courses Plus Student 1,740 Points

I honestly dont know what the back sticks are.
this, \ or this, '

The backtick character is right below the esc key.

Here: `

Note that the backtick character ` isn't the same as the single quote character '

You got it :+1: