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