Note: If you are a remote student and you are going through these lessons with a pair, you'll need to screen share your Chrome DevTools console with your pair (more instructions below). We prioritize using the browser console (and other dev tools) because it's such a vital tool to be proficient with as a developer.
We're going to take a detour away from the aesthetically pleasing and obviously useful world of web pages so that we can learn some programming fundamentals. But don't worry! We'll be back in no time.
Here are the shortcuts to access the DevTools:
1 + 2; and pressing Enter.
You should see something like:
> 1 + 2; 3
1 + 2 - evaluated it, and returned the result:
This is called an expression. An expression in computer programming is code that evaluates a value.
Now try these:
4 - 3;
5 * 6;
10 / 2;
9 / 2;
7 + 8 * 9;
(7 + 8) * 9;
/ are called operators. An operator is a special character (or characters) that indicates an action to be performed.
Try dividing 0 by 0. The result,
NaN is actually considered a type of number (bizarre as that may seem).
Try dividing any other number by 0. The result,
% are called operators. An operator is a special character (or characters) that indicates an action to be performed.
9 % 2; returns the remainder of 9 divided by 2.
% is called modulo.
0 / 0; returns
NaN, which stands for not a number.
NaN is a type of number.
Infinity is also a number.
Basic arithmetic works just like you'd expect:
1 + 2; 4 - 3; 5 * 6; 9 / 2; 7 + 8 * 9; (7 + 8) * 9;
Lesson 6 of 65
Last updated May 23, 2022