This practice will be retired on May 31, 2020.
Solution: Working With Numbers1:35 with Pasan Premaratne
In this practice session, your goal was to mimic the output I had provided. 0:00 So here's my solution. 0:04 Now again yours doesn't need to be the exact same code as mine. 0:06 We'll see in a second that you can tweak it subtly. 0:08 All we need is that final end result. 0:12 So here we have two constants. 0:14 I've named the first one firstValue and the second secondValue. 0:16 So again, we start with the keyword let to create a constant, give it a name. 0:19 And then using the equal sign, we assign the value 10 to it. 0:23 And same for 20. 0:28 The next thing we do is we multiply those two values and 0:29 assign the result to a constant name result. 0:33 So again, keyword let, name result, and here is the assignment bit. 0:37 For the final part, 0:41 we need to get a string literal out of this that describes the operation. 0:42 And the way we do this is by passing in the values we defined. 0:47 So the value of multiplying and we specify firstValue, so 0:50 it doesn't matter what firstValue is because the constant 0:54 already contains that value, so it's just going to print it out. 0:57 And then we'll do the same thing for secondValue and then the result. 1:01 Now, one new thing that we may not have covered and that might be new to you. 1:04 Is that you don't necessarily need to do this here where you compute the value 1:09 by multiplying firstValue and secondValue and then assign to result. 1:14 You can actually do that in line here. 1:18 Now, this is a nice thing to know for now. 1:20 For example, if I copy this and paste that in there, 1:23 I'll still have the same results, but I don't need this extra constant. 1:26 Okay, I hope you got that as well. 1:32 Onto the next exercise. 1:34
You need to sign up for Treehouse in order to download course files.Sign up