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

Brian Uribe
Brian Uribe
3,488 Points

What is wrong with this code?

I'm trying to figure out what is wrong with this code?

strings.swift
let name = "Brian."
let greeting = "Hi there, \(name)"

let finalGreeting = "greeting + "" How are you?"

2 Answers

Marc Schultz
Marc Schultz
23,356 Points

You have too much quotation marks inside this:

let finalGreeting = "greeting + "" How are you?"

The variable greeting should not be surrounded by quotation marks.

let finalGreeting = greeting + " How are you?"
Brian Uribe
Brian Uribe
3,488 Points

I tried it without the quotes. I was using the quotes to create a space between the two pieces of text. It still didn't work.

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

I just ran Marc's corrections and both tasks passed. Your code for task one is correct

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

And Marc's correction is correct for task 2

let finalGreeting = greeting + " How are you?"

For task 2, make sure you are adding the line of code to the ones you've already entered... don't delete anything.

:)

Brian Uribe
Brian Uribe
3,488 Points

I guess I didn't read the first response carefully enough, I got it to work.