-
Notifications
You must be signed in to change notification settings - Fork 0
/
Functions_V(scope).js
53 lines (48 loc) · 1.03 KB
/
Functions_V(scope).js
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
// ==============
// FUNCTION SCOPE
// ==============
let totalEggs = 0;
function collectEggs() {
totalEggs = 6;
}
console.log(totalEggs);
collectEggs();
console.log(totalEggs);
const bird = 'Scarlet Macaw';
function birdWatch() {
const bird = 'Great Blue Heron';
console.log(bird);
}
birdWatch()
// ==============
// BLOCK SCOPE
// ==============
// let radius = 8;
// if (radius > 0) {
// const PI = 3.14159;
// let msg = 'HIII!'
// }
// console.log(radius);
// console.log(msg)
// for (let i = 0; i < 5; i++) {
// let msg = "ASKLDJAKLSJD";
// console.log(msg)
// }
// console.log(msg)
// console.log(i)
// ==============
// LEXICAL SCOPE
// ==============
function bankRobbery() {
const heroes = ['Spiderman', 'Wolverine', 'Black Panther', 'Batwoman']
function cryForHelp() {
let color = 'purple';
function inner() {
for (let hero of heroes) {
console.log(`PLEASE HELP US, ${hero.toUpperCase()}`)
}
}
inner();
}
cryForHelp();
}