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 trialvernell blackman
123 PointsHello I am taking the swift 2.0 class and i am on a challenge question and can't seem to get past it.
Challenge 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, Pasan. How are you?β
let name = "Vernell." let greeting = "Hi there," let interpolatedgreeting = "(greeting) (name)"
let finalGreeting = "How are you?" let concatenateaddress = "(greeting) (name) (finalGreeting)
I don't really understand the question and the use of the word literal and how I'm suppose to use it. The first challenge question was fine but this one i don't know.
let name = "Vernell."
let greeting = "Hi there,"
let interpolatedgreeting = "\(greeting) \(name)"
let finalGreeting = "How are you?"
let concatenateaddress = "\(greeting) \(name) \(finalGreeting)
3 Answers
jcorum
71,830 PointsI agree. It's misleading!
Happy coding.
jcorum
71,830 PointsAlmost, but "interpolated greeting" was instructions on what to do rather than the name of a variable. Note that there's no period after your name. The editor is picky, and just wanted your name in the name variable. Also, it's important that the String " How are you?" start with a space, as greeting doesn't end with one and you need one between the two.
let name = "Vernell"
let greeting = "Hi there, \(name)."
let finalGreeting = greeting + " How are you?"
You could also do the last one like this (outside the challenge):
let finalGreeting = greeting + " " + "How are you?"
to get the space, but the first way is usually better.
vernell blackman
123 PointsThank you, i see what you did but i don't understand why "finalgreeting" is there in the first place, i don't know but to me in this question its like it was just there to mess people up.
vernell blackman
123 PointsHey i am on this other challenge question that i don't understand, I've been messing around and staring at my playground for a long while trying to think of something but i don't understand.
the is the question...
Challenge Task 2 of 2 Given these two values we just declared, we want to compute the product and print out the product in a formatted string. β¨Step 1: Declare a constant named product and assign the result of multiplying firstValue and secondValue together. (To multiply two values, a and b, we write a * b). β¨Step 2: Using string interpolation, create a string literal that describes the operation we just performed. For example, given the following values for firstValue, secondValue and product respectively: 2, 4, 8. The string should read: "The product of 2 times 4 is 8". Assign this string to a constant named output.