-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
106 lines (89 loc) · 2.41 KB
/
example.js
File metadata and controls
106 lines (89 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
console.log("\"howdy\"", 10, "🤠")
console.warn("whoa look here!")
console.error("Ruh Roh!")
console.clear()
// DATA TYPES (PRIMITIVE TYPES)
// STRING (think text content)
let greeting1 = "Hello"
let greeting2 = 'howdy'
var greeting3 = `wassup` // var is "outdated"
console.log(greeting1)
// NUMBERS (think numbers)
// ☝️🤓 Technically numbers in JS are "Floats"
let crocsOwned = 6
let wishedCrocsOwned = 100
let crocsDestroyedCount = -2
let crocCoolFactor = 10.99
// BOOLEANS (think ABSOLUTE)
let toBe = true
let notToBe = false
// BOOLISH (think IDK could it be there?)
let truishNum = -99000 // any value other than 0
let falseishNum = 0
let truishString = "any string with characters in it"
let falseishString = ""
// UNDEFINED & NULL (Think missing or empty)
let unknown
let knownNothing = null
// Operators
// = assignment
// the left item holds the value of the right data
let x = 10
x = 20 // re-assignment (giving an already create variable a new value)
// Math + - * /
x + 1 // add
x - .5 // subtract
x * 100 // multiply
x / 20 // divide
console.log(x) // Math is just math, it doesn't change the value of the variables it's operating on
// Math RE-ASSIGNMENT
// does the math AND re-assigns the value of the variable together
x += 1
x -= .5
x *= 100
x /= 20
console.log(x)
// Weird JS that math can do? (really only add)
let string1 = "hi there"
let string2 = "how are you"
string2 += "-This is so cool"
console.log(string1 + string2)
let stringOrNum = "10" + 10
console.log(stringOrNum)
let numOrString = 5 - "10"
console.log(numOrString)
// comparisons
// comparisons CREATE BOOLS
// equality
10 == 10 // => true
10 == 5 // => false
// less than
10 < 100 // => true
10 > 100 // => false
10 >= 100 // => false
// greater than
100 > 10 // => true
10 > 100 // => false
10 >= 100 // => false
console.log(10 >= 5)
// loose comparison ==
// strict comparison === | >== | <==
10 == "10" // => true
true == 1 // => true
true === 1 // => false
10 === "10" // => false
console.log(x === 500)
// Functions
// Block of code to be called later, typically to be repeated or to organize your code better
// let is a block scoped variable, it can only be accessed inside of it's "block"
let count = 0
function doTheThing() {
// debugger lets you pause the code on this line
count += 1
console.log("Doing the thing🤠", count)
}
// count = "👢"
console.log('🦧', count)
let doTheOtherThing = () => {
console.log("Other Thing 🐶")
}