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!
We're looking for feedback on this new type of practice workshop. When you're finished, could you please review the workshop by filling out this short form?
Required Downloads

0:00
Okay, so I said there were two ways to do this.

0:02
One was, we can break this down into the individual steps and

0:06
that makes it fairly easy.

0:07
So here I got the distance between x, I use the subtraction operator to get that

0:12
distance, and then we square the distance so we multiply this value by itself.

0:18
We repeat that for the y values.

0:21
We add those two together.

0:22
And then we put them here in the square root, between these parenthesis here,

0:27
like I mentioned to get the final value.

0:29
So the distance between our two points is 4.47 whatever the units.

0:34
Now, the other way to do it was all in one single line using the correct precedence

0:39
and using parentheses to define that precedence accordingly.

0:42
So, I've added a comment here so it doesn't execute but

0:45
if I remove this, you'll see that the code runs and it is the exact same value but

0:49
this is all in one line.

0:51
Now obviously, I would go with this approach if I were you,

0:55
because this is a bit more readable.

0:57
So until you understand what's going on here, this is all unnecessary.

1:01
And there's ways down the road, once you learn how to write more code,

1:05
there's ways to improve this, so it's not so unreadable, basically.

1:09
Okay, so hopefully, you got that right.
You need to sign up for Treehouse in order to download course files.
Sign up