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

Jericoe States
Jericoe States
3,262 Points

let name = "Jericoe" let greeting = "Hi there," let interpolatedName = "\(greeting) \(name)" // will not correct

//This is the the code I've put together. On Xcode, my code works. On Treehouse the code is wrong, in addition it won't preview or help me figure it out.

it show an "output.html" which is blank.

let name = "Jericoe" let greeting = "Hi there," let interpolatedName = "(greeting) (name)

strings.swift
let name = "Jericoe"
let greeting = "Hi there,"
let interpolatedGreeting = "\(greeting) \(name)"
Jericoe States
Jericoe States
3,262 Points

I feel stupid...

thanks a lot man! appreciate it

2 Answers

You are very close and have the right idea. Sometimes I have to reread the instructions to make sure I'm doing EXACTLY what they want me to do.

Directions and (Your code): In this task we're going to declare two strings. (Your code has 3 declared strings)

First, declare a constant named name and assign to it a String containing your name. (Correct)

Second, declare a constant named greeting. (Correct)

Set the value of greeting to an interpolated string that combines "Hi there, " with the string stored in the name constant. (Your code only has "Hi there,")

I'm trying to point you in the right direction without giving the actual code. I believe it helps us think it out better. Too many people just give us the code in our answers and that really doesn't help us figure it out so we remember it.

Hint: There should only be 2 constants, the second constant should be your interpolated string.

let me know if that helps.

Jericoe States
Jericoe States
3,262 Points

it does! I thought It needed more lines... I thought to create interpolated code, I had to use interpolated as a heading for example.

interpolatedGreeting - where interpolated is more so a way to insert code -> "Hi there, (Jericoe)".

Thank you. Jay.

Jeff McDivitt
Jeff McDivitt
23,970 Points

This is all the the code is asking

let name: String = "Jeff"
let greeting = "Hi there, \(name)"