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

Magnus Lindberg Christensen
Magnus Lindberg Christensen
2,231 Points

Swift code not working

Hey there.

I've written the following code in the Swift code challenge, but for some reason I cannot make it work. every time I check work it just says:

" Bummer! Make sure the value you are assigning to greeting is an interpolated string"

what have I done wrong? the code is supposed to bring the output: "Hi there, Magnus. How are you?"

strings.swift
// Enter your code below

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

Hey there Magnus! I'm not infront of my computer but the solution is redundant you are using concatenation and interpolation but you really just need interpretation. Try removing the + and make it just one big string with your interpolated properties "()()"

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

Hope this helps buddy!

1 Answer

Christian Mangeng
Christian Mangeng
15,970 Points

Hi Magnus,

I think you mixed up the variables greeting and finalGreeting. It is finalGreeting that should contain the concatenated string. Also, it is the "Hi there, (name)." that needs to be stored in a variable, not the "How are you". Hope that helps.

Good luck