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

Don't understand what I am doing wrong. this is my code let name = "Ceejay" let greeting = "\(Hi, there) \(name)"

Don't understand what I am doing wrong. this is my code let name = "Ceejay" let greeting = "(Hi, there) (name)"

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

2 Answers

Matthew Long
Matthew Long
28,407 Points

You're not far from the answer. However, the "Hi there, " portion of the greeting does not need to be inside a pair of parentheses. Also, pay attention to the string the challenge is expecting. For example, you have a comma after Hi, but the challenge does not expect one there.

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

Lastly, pay attention to the second part of this challenge. It is wanting string concatenation! You will need to use the plus operator, + this time.

Oh yeah!! Thank you very much

Jialong Zhang
Jialong Zhang
9,821 Points

White space matter in this challenge.

let name = "Ceejay"
let greeting = "Hi, there,\(name)"   //with no space, output:  "Hi, there,Ceejay"
let greeting2 = "Hi, there, \(name)" //with space, output: "Hi, there, Ceejay"