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

Philipp Hahn
Philipp Hahn
1,366 Points

again stuck in task 2, something I do wrong again - let finalGreeting etc. I thought this code makes sense

I thought this code made sense as Xcode didnt complain, but I seem not to understand the question again properly. What is the wrong part of my code, always get the bummer answer ^^ Thanks for the support.

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

2 Answers

The challenge didn't pass as correct here because the second task asks you to concatenate another string to the greeting string, not to use string interpolation.

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

let finalGreeting = greeting + " How are you?" //  Prints "Hi there, Ana. How are you?

In your code, aside from using string interpolation instead of concatenation, the value of finalGreeting would print, "Hi there, Ana. Ana How are you?"

Philipp Hahn
Philipp Hahn
1,366 Points

thank you so much, yes I realized the mistakes. Thank you for helping out :)