iOS Swift Basics Swift Types Recap: Swift Types

Some help

How do I go about this

// Enter your code below
let firstValue = 23
let secondValue = 32
let product = (23*32)

2 Answers

Alex Koumparos
Alex Koumparos
Python Web Development Techdegree Student 35,917 Points

Hi Gerald,

The question tells you:

Declare a constant named product and assign the result of multiplying firstValue and secondValue together.

You have multiplied two number literals together (23 and 32) and haven't used firstValue or secondValue.



William Li
William Li
Courses Plus Student 26,837 Points

hmmm ... I was asked to answer this question.

As Alex has pointed out, you shouldn't perform the multiplication on the two raw numerical values, replace 'em w/ the two constants instead. On top of that, it's unnecessary to put the parenthesis () around them. Parenthesis is used in the case when you need to change the operator precedence in the calculation. e.g. (3+2) * (5+2), in this case, the parenthesis is necessary because you want to force the addition to be performed before the multiplication, otherwise just leave the parenthesis out when it's not needed. In Swift, parenthesis happens to be also a language construct for creating a data structure, putting the extra parenthesis in the code that doesn't need to be there would only create visual noise for the reader of the code.

Also, Part 2 of the challenge has TWO steps, don't forget to complete the step 2 of creating a string literal to pass the challenge.

happy coding.