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

Rayhan Miah
Rayhan Miah
2,369 Points

What is the problem with this code

what is the problem with the last part final greeting

strings.swift
// Enter your code below
let name = "Rayhan"
let greeting = "Hi there, \(name)."

let finalGreeting = "\(greeting). how are you?"

1 Answer

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

Hi there! You're doing well, but the challenge explicitly asks for the finalGreeting to use concatenation. You're using interpolation. They're testing your ability here to achieve similar results using different methods. And not that this would make the challenge fail, but you have an extra period in your string and the "h" isn't capitalized. Currently your string would look like this if printed: "Hi there, Rayhan. . how are you?", which isn't exactly what we're after.

String interpolation is the use of backslash and parentheses to insert the value of a variable into that spot inside a string literal. Concatenation is putting two strings together using a plain old plus sign. Take a look at how close you are!

// Enter your code below
let name = "Rayhan"
let greeting = "Hi there, \(name)."

let finalGreeting =  greeting + " How are you?"

Happy coding! :sparkles: