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

codyl
codyl
4,704 Points

Works in xcode - Maybe I'm not doing it the way they're asking?

I don't think the challenge is very clear. I'm pretty sure I'm doing it the way they're asking me to do it. Can someone suggest what might be off?

strings.swift
// Enter your code below
let name = "Cody"
let message = "Hi there"
let greeting = "\(message), \(name)"
let finalGreeting = "\(greeting). \("How are you?")"

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Cody,

While the code is correct and will work, it is not what the instructions for the challenge are asking for.

For Task one, there should be only two variables. The name and the greeting one. the value of greeting will use interpolation to output "Hi there, (name)". So, your message variable wasn't asked for and needs to be deleted.

Now the second challenge explicitly asks for concatenation to be used, but you are still using interpolation. Once you fix those up, you're all good.

Remember, instructions for challenges are very specific and need to be followed exactly or you'll more than likely get the Bummer!. Even if code is correct and works locally, if it's not exactly what is asked for, it won't work. Even something as small a missing period or a capital letter instead of a lower-cased one..." Very picky...

Nice work! :) :dizzy:

Gundra Kiran
PLUS
Gundra Kiran
Courses Plus Student 5,931 Points

Hi Cody,

You are code has no error but in the challenge, the editor is expecting an exact solution for which it has been programmed. For suppose above code challenge. The first task is of interpolation where the concept of using any variable in double quations "()"and the second concept is concatenation means adding two strings using + plus symbol. I am posting my solution take a look and rectify yours

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