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

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,858 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: