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 trialPema Khando Shachentsang
Courses Plus Student 1,210 PointsSwift types
let firstValue = 1 let secondValue = 2 let product = "firstValue*secondValue" let firstValue = 2 let secondValue = 4 let product = "firstValue*secondValue"
need some helps
// Enter your code below
let firstValue = 1
let secondValue = 2
let product = "firstValue*secondValue"
let firstValue = 2
let secondValue = 4
let product = "firstValue*secondValue"
2 Answers
Apoorva S
998 PointsThat error message on the following lines, let firstValue = 2 let secondValue = 4 let product = "firstValue*secondValue"
means that you have created two variable with the same name. That is,
let firstValue = 1 let firstValue = 2
Points to observe:
-
firstValue, secondValue, product have been declared as let; constant, wherein the value cannot be changed. incase you want to change the value (firstValue = 2, secondValue = 4, product = "firstValue*secondValue") change let to var.
var firstValue = 1 var secondValue = 2 var product = firstValue*secondValue
-
Don't redeclare firstValue, secondValue, product. Simply use it as
firstValue = 2 secondValue = 4 product = firstValue*secondValue
which will allow you to assign new value and perform multiplication.
lastly: let product = "firstValue*secondValue" The above line will not perform multiplication - "firstValue*secondValue" This is just a string which is assigned to 'product' variable.
Pema Khando Shachentsang
Courses Plus Student 1,210 Pointsthanks