Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Basics Swift Types String Manipulation

I keep getting the right result in x code but I am not sure what order to put it in on the test.

I keep getting the correct result on x code?

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

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,692 Points

Hi Chris,

You're more or less on the right track. However, even though your code is syntactically correct and functional, it is not what the instruction are asking for. Challenges are very specific and need to be followed explicitly.

  • The first task asks for a string the says "Hi there, <name>" but you have "<name> How are you?"
  • The second task asks for a string that 'concatenates' the first string with "How are you?", but you are still using interpolation and aren't outputting the correct string.
    Have a look:
// Enter your code below
let name = "Chris"
let greeting = "Hi there, \(name)"
let finalGreeting = greeting + " How are you?"

You'll notice the greeting is using interpolation while the finalGreeting is using concatenation.

It'll be good to keep in mind how picky challenges are. Just because it works doesn't mean it's correct. Other than that... good job. :thumbsup:

Keep Coding! :) :dizzy: