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 trialNeovera AS
Full Stack JavaScript Techdegree Student 4,000 Pointsinterpolated string
Hi everyone, I am trying to solve a quiz from Swift Basics and am puzzled as to my code is not being accepted.
The question is to declare two strings. name greeting
and set a value of greeting to an interpolated string that combines the string value from both name and greeting. When I write the code in quiz area, it does not work, when I write the same code in xcode playground, it works perfectly. I don`t understand what is wrong in my code...hope to get some hint about this...thanks. Cheers.
// Enter your code below
let name = "Dildar"
let greeting = "Hi there"
// String Interpolation
let interpolatedGreeting = "\(greeting), \(name)"
8 Answers
Nico Schmidt
12,781 PointsThat should do.
// Enter your code below
let name = "Dillar"
let greeting = "Hi there, \(name)"
Concatenation is used in the second part of the challenge.
Nico Schmidt
12,781 PointsI can give you some hints.
The challenge asks for concatenation and not interpolation.
By the way i would name the last constant finalGreeting, to be on the save side.
It should now be easy for you to solve.
Neovera AS
Full Stack JavaScript Techdegree Student 4,000 PointsThank you Nico Schmidt I will try again :)
Neovera AS
Full Stack JavaScript Techdegree Student 4,000 PointsI have just tried it again with concatenation and it still doesnt work.
I have tried several options and can
t find the solution...
By the way, it is mentioned in the challenge to set the value of greeting to an interpolated string that combines the value of greeting and name...so I am not sure how it should be written...any other hints?? Thanks
Neovera AS
Full Stack JavaScript Techdegree Student 4,000 Pointswow...that was awesome! Thank you so much for your help Nice :) I am new to programming and very excited about learning all I can. This one was a little tricky, I think I did not understand the question properly. Now I get the question as well. Thank you again for your help. Awesome! Cheers.
Nico Schmidt
12,781 PointsThats great. Keep it up ;)
Neovera AS
Full Stack JavaScript Techdegree Student 4,000 PointsThanks again. And sorry for the misspelling your name. I meant Nico :)
Neovera AS
Full Stack JavaScript Techdegree Student 4,000 PointsHi again Nico, Next question is:
Declare a constant named finalGreeting, and concatenate the value of greeting with the string literal " How are you?".
I am trying it write it like this: let finalGreeting = "(greeting). How are you?"
and abviously it is not working :) Just curious what am I doing wrong? I tried other options as well...
Nico Schmidt
12,781 PointsYour task is to concatenate.
// Enter your code below
let name = "Dildar"
let greeting = "Hi there, \(name)"
// String Interpolation
let finalGreeting = greeting + ". How are you?"
Neovera AS
Full Stack JavaScript Techdegree Student 4,000 PointsAmazing. That was not taught during the lessons or maybe I did not notice :) Thank you again for your prompt response, very much appreciated.
Cheers