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

I just can't figure out how to do this.

Please let me know what i'm doing wrong. Thank you so much.

strings.swift
// Enter your code below
let name = "zach"
var whatever = "Hi there"
let finalGreeting = "How are you"
let greeting = "\(whatever), \(name) + finalGreeting"

2 Answers

Tobias Helmrich
Tobias Helmrich
31,603 Points

Hey Zachary,

the problem is that you should use interpolation for the greeting constant and concatenation for the finalGreeting constant. However you're saving your final greeting into the greeting constant and your string concatenation doesn't work because you're writing your constant finalGreeting inside of quotes. Also note to write all the punctuation characters like "?" and the period the challenge wants you to write.

Besides that you should use string interpolation for the greeting constant which means that you actually don't need the "whatever" variable.

It should work like this:

// Enter your code below
let name = "Zach"
let greeting = "Hi there, \(name)."
let finalGreeting = greeting + " How are you?"

I hope that helps! :)

Martin Wildfeuer
PLUS
Martin Wildfeuer
Courses Plus Student 11,071 Points

According to the assignment, you first have to assign a string to greeting by interpolation. The string final greeting has to be assigned via concatenation. That would look like the following:

let name = "Zach"
let greeting = "Hi there, \(name)"
let finalGreeting = greeting + " How are you?"

Hope that helps :)