iOS Swift Basics Swift Types String Manipulation

codyl
codyl
4,685 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 143,698 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
PRO
Gundra Kiran
Pro 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?"