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 Swift Types String Manipulation

i don't know how to code it please tell me

i don't know how to code it please tell me

strings.swift
// Enter your code below
let name = Rashed
let greeting = Hi There ! let ed = "\(Hi There !) , \(name)"

2 Answers

Hi Rashed,

You're not so very far away with your code. Good work!

First, you want to store your name in a constant called name. This is a string, which you need to surround with double inverted commas:

let name = "Rashed"

Next, you've nearly got the greeting bit right. We want the final string to say "Hi there, Rashed" using the constant you created above, called name. You have correctly identified that the backslash and brackets surround the constant name will do this. You just didn't quite get the string right. So, you'd done the hard bit!

Try something like:

let greeting = "Hi there, \(name)"

That should get you through the first bit of the challenge.

Steve.

Michael Afanasiev
PLUS
Michael Afanasiev
Courses Plus Student 15,596 Points

Hi Rashed,

Let's go over this step by step:

First step: declare a constant named name and assign to it a String containing your name.

let name = "Rashed"      <---------- Remember that a string must be between 2 quotation marks

Second step: declare a constant named greeting. Set the value of greeting to an interpolated string that combines "Hi there, " with the string stored in the name constant.

let name = "Rashed"
let greeting = "Hi there, \(name)"

String interpolation is written with the \(someVar) notation and must be only written inside the string. Don't worry if you don't get the hang of it the first few times, the more you will code the more it will sink in, trust me!

I hope this information was helpful to you, now go and pass the 2nd task of this challenge! Good luck! ?

:+1: :smile:

Good work!

?????????????????????????

Cool emoji!