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

Julio Apodaca
Julio Apodaca
407 Points

Can't solve interpolated greeting

let name = "David" let greeting = "Hi there" let interpolatedGreeting = "(greeting), (name)"

This is working on Xcode but not on the quiz question. I just copied from Xcode and pasted it on the quiz and it gives me an error.

strings.swift
// Enter your code below

let name = "David"
let greeting = "Hi there"
let interpolatedGreeting = "\(greeting), \(name)"

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Julio,

While the code is technically correct, it is not what the challenge asked for. Challenges are very specific, and the instructions need to be followed exactly as they are written.

So, first, the instructions did not ask for a constant named interpolatedGreeting, so that needs to be deleted. To complete this Task, there should only be 2 lines of code. The name constant and the greeting constant.

It is in the greeting constant that you are to set the value

to an interpolated string that combines "Hi there, " with the string stored in the name constant.

So, you are on the right track, you just need to fix up the code to match what the Task is asking for.

You are also missing the comma after "Hi there" ... without the comma, the task will fail. (Again, Challenges are very picky).

Keep Coding! :) :dizzy: