Lab work 4 - AT THE GATES OF ENLIGHTENMENT - JavaScript in Plain Language (2015)

JavaScript in Plain Language (2015)

PART I: AT THE GATES OF ENLIGHTENMENT

1.10 Lab work 4

Practicing with ===, !==, <, >, <=, >= true, false.

Go to your favorite JavaScript Console and create some variables and values.

1- Ask JavaScript if 12 is greater than 14.
Then ask if 12 is smaller than 14.

2- Declare variable num with a value of 12.
Then declare variable num2 with the value of "12".
Later, ask if num is the same as num2.

3- Ask if num is not the same as num2.

4- Ask if 7 is greater or equals to 8.
Also if 7 is less or equals to 7.

5- What is the difference between true and "true"?

6- Find out the typeof true.

7- Find out the typeof "true".

8- Find the type of value "7".

9- Find the type of value 8.

(see results on the next page).

Results:

1- Ask JavaScript if 12 is greater than 14.
Then ask if 12 is smaller than 14.
12 > 14;
false
12 < 14;
true

2- Declare variable num with a value of 12.
Then declare variable num2 with the value of "12".
Later, ask if num is the same as num2.
var num = 12;
var num2 = "12";
num === num2;
false

3- Ask if num is not the same as num2.
num !== num2;
true

4- Ask if 7 is greater or equals 8.
Also if 7 is less or equals 7.
7 >= 8;
false
7 <= 7;
true

5- What is the difference between true and "true"?
true is a reserved Boolean term.
"true" is just a string of characters.

6- Find out the typeof true.
typeof true;
"boolean"

7- Find out the typeof "true"
typeof "true";
"string"

8- Find the type of value "7".
typeof "7";
"string"

9- Find the type of value 8.
typeof 8;
"number"