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 2.0 Basics Swift Types Recap: Swift Types

Abhash Malviya
Abhash Malviya
2,890 Points

Identify where i am wrong

Please can anyone identify where I am wrong

types.swift
// Enter your code below
let firstValue = 4
let secondValue = 6
let product = a * b
let output ="\("the product of") \(firstValue) \("times") \(secondValue) \("is") \(product))"

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,624 Points

Hey Abhash,

There are a few issues happening here:

  1. For the let product line, you haven't declared any variable called a or b. This line, you should be using the variables that you declared in Task one -- firstValue and secondValue.

  2. There needs to be a space between the = sign and the opening quotes for the interpolated string.

  3. The interpolated string is not formatted correctly. I do highly recommend that you re-watch the String Interpolation video to review the proper formatting. There should be only one opening quotation mark and one closing quotation mark (You have 8). Only the variables are put inside the interpolation syntax \(). The actual hard coded strings are just as normal strings.

  4. The instructions are always very specific and very picky. So the first word in the string the needs to be capitalized to The.

I've provided the corrected code, but I very much recommend that you review this course before moving on, as variables and sting interpolation and string concatenation is very important in the future videos. Just make sure you have a strong understanding of "Types" before moving on to "Operators".

let firstValue = 4
let secondValue = 6

let product = firstValue * secondValue

let output = "The product of \(firstValue) times \(secondValue) is \(product)"

Keep Coding! :dizzy:

Abhash Malviya
Abhash Malviya
2,890 Points

Hi Jason,

Thank You very much I totally understood where I went wrong. Thanks for the input

Thanks