Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Basics Swift Types Recap: Swift Types

Yvon Joseph
seal-mask
.a{fill-rule:evenodd;}techdegree
Yvon Joseph
iOS Development Techdegree Student 201 Points

Compiling error

Challenge Task 2 0f 2:

TreeHouse compiler not giving the same result as XCode. XCode results appear correct let firstValue = 2 let secondValue = 4 let product = firstValue * secondValue let outputs: String = "The product of" let output: String = "(outputs) (firstValue) * (secondValue) is (product)"

TreeHouse does not accept and asks me to double check the example provided

What do I do ?

types.swift
let firstValue = 2
let secondValue = 4
let product = firstValue * secondValue
let outputs: String = "The product of"
let output: String = "\(outputs) \(firstValue) * \(secondValue) is \(product)"

1 Answer

andren
andren
28,521 Points

Treehouse challenges are very picky when it comes to text output, your code will often be marked as wrong if the string you produce does not match the string that is requested exactly.

The string you produce looks like this:

"The product of \(outputs) \(firstValue) * \(secondValue) is \(product)"

The string they look for is this:

"The product of \(outputs) \(firstValue) times \(secondValue) is \(product)"

Notice that in your solution you use the * symbol whereas the string the challenge asks for uses the word times instead.

If you fix that discrepancy then your code will pass.

It's also worth mentioning that while it's not an issue in this task the code checker for these challenges is often quite picky not just about the result of your code but about how your code is actually structured as well.

Creating variables/constants that are not explicitly asked for (like the outputs constant in your solution) will often end up confusing the code checker and can result in your code being marked as wrong even if it produces the right result. It is therefore recommended that you try to always keep your solution code as simple as it can while still completing the challenge criteria.

Yvon Joseph
seal-mask
.a{fill-rule:evenodd;}techdegree
Yvon Joseph
iOS Development Techdegree Student 201 Points

Wow Andren,

Your knowledge is unreal ! Thank you once again for you assistance and clarification. I will read and re-read the question in future to get a good understanding on what the challenge and requirements are.

These issues are so annoying lol, but I need move past that lol

Regards Yvon