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 trialTONY COLAROSSI
480 Pointscant complete ch. task 1 of 2 pls help
in swift i do: let name = "Tony." let greeting = "Hi There" let interpolatedGreeting = "(greeting), (name)" and it works perfectly.. "Hi There, Tony."
i cant do it with 2 lines as per question
// Enter your code below
let name = "Tony."
let greeting = "Hi There"
let interpolatedGreeting = "\(greeting), \(name)"
5 Answers
Jens Hagfeldt
16,548 PointsHi Tony, maybe the second part of the challenge is a bit confusing to understand. In the challenge the second part was described as follows:
Second, declare a constant named greeting. Set the value of greeting to an interpolated string that combines "Hi there, " with the string stored in the name constant. As an example, the final value of greeting could be "Hi there, Linda.".
An interpolated string is a string in which you combine usual string characters and a stored value, such as the constant name for example. The stored value (name) is written inside of a pair of parentheses behind a backslash like in my example here below.
// Enter your code below
let name = "Jens"
let greeting = "Hi there, \(name)."
I hope this explanation helped! / Jens
Ary de Oliveira
28,298 PointsChallenge Task 2 of 2
Now that we have an appropriate greeting for our user, let's make a bit more polite by concatenating the greeting string with a second string literal.
Declare a constant named finalGreeting, and concatenate the value of greeting with the string literal " How are you?".
Example: "Hi there, Ary. How are you?"
let name = "Ary de Oliveira"
let greeting = "Hi there, \(name)."
let finalGreeting = "\(greeting)" + "How are you?"
Ary de Oliveira
28,298 PointsChallenge Task 1 of 2
In this task we're going to declare two strings. First, declare a constant named name and assign to it a String containing your name.
Second, declare a constant named greeting. Set the value of greeting to an interpolated string that combines "Hi there, " with the string stored in the name constant.
As an example, the final value of greeting could be "Hi there, Ary".
let name = "Ary de Oliveira"
let greeting = "Hi there, \(name)."
Farhad Mohammad Afzali
5,007 PointsHi, here is my solution:
let name = "Linda" let greeting = "Hi there, (name) ."
I hope it helps.
ttaleg
9,830 Pointswhy didnt it let me just concontinate them first and then interpolate? >_< sheesh