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

Xcode running code fine but browser challenge not accepting code!

Hi, I am currently doing the challenge for swift basic 3.0, looking at constants and my code is running with no errors on Xcode but the browser part of the challenge is displaying that 'I need to assign the correct string to the variable'.

Does anyone see what I'm missing in my code or know whats going on please?

strings.swift
// Enter your code below
var language = "Swift"
var langauge = "Objective-C"

let favoriteDessert = "Cheesecake"

let name = "Jack"

let greeting = "Hi there,"

let interpolatedgreeting = "\(greeting) \(name)"

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Jack. Welcome to Treehouse.

First off, I see 3 lines of code that are not part of this challenge (the first three), so those need to be deleted.

You didn't specify which task you are one (1 or 2), but I'm going to guess #1 based on the error this code generates. While the code is correct in syntax and will run, it is not what the challenge asks for. Instructions are very specific and must be followed exactly or the code will get the Bummer.

You have the first part of Task 1 correct (in assigning your name constant), but the second part is where you may have misread the instruction. It says to

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.

You have the constant with "Hi there, " but you don't have the interpolated name variable there... The instructions do not say to create a constant named interpolatedgreeting, so that needs to be deleted and the interpolation needs to be done in (combined with) the greeting constant.

So, you do have all the 'ingredients', now you just need to put them in the right spot, as per the instructions.

Hope this helps! :) :dizzy:

Thanks Jason! All sorted now, appreciate the fast response and help!