Skip to content

Commit 6265a0b

Browse files
paulinetheitgirlTanya Butenko
authored andcommitted
Empty vs. undefined, more about Booleans (#13)
* Use Crockford terminology: "Vars which are not explicitly initialized are given the value undefined." https://www.crockford.com/javascript/survey.html * Change casing of Boolean reserved words. Add section for Boolean NOT operator.
1 parent badce62 commit 6265a0b

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

js/level1.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@
6464
var variableName;
6565
6666
So, we created a variable named variableName, but it has no information or
67-
value inside. It is empty. To give our variable a value (initialize it)
68-
use the '=' sign:
67+
value inside. It is undefined.
68+
69+
console.log("variableName is", variableName);
70+
71+
To give our variable a value (initialize it) use the '=' sign:
6972
7073
variableName = 'Hello world!';
7174
@@ -80,10 +83,10 @@
8083
Strings - set of characters, word(s), or phrases that we wrap in quotes, like
8184
'hello world!'
8285
Numbers - either integers or floats(decimals). Not wrapped in quotes
83-
Boolean - it represents logical values - True or False
86+
Boolean - it represents logical values - true or false.
8487
*/
8588

86-
// TODO: Now create two empty variables named numberOne and numberTwo.
89+
// TODO: Now create two undefined variables named numberOne and numberTwo.
8790

8891

8992

@@ -314,6 +317,20 @@
314317

315318

316319

320+
/*
321+
Boolean Operators
322+
=================
323+
Putting an exclamation (!) before a Boolean variable gives
324+
the opposite value. The ! is called a "not" operator when
325+
used this way.
326+
327+
// the result of a comparison is a Boolean value, so we can
328+
// save it to a variable
329+
var bool = (1 < 2);
330+
console.log(bool);
331+
console.log(!bool); // "not true", therefore false
332+
console.log(bool); // the original value isn't affected
333+
*/
317334

318335
///////////////////////////////////////////////////////////////////////////
319336
// Congratulations! You have finished Part 1 of JavaScript Basics! //

0 commit comments

Comments
 (0)