-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
112 lines (85 loc) · 1.55 KB
/
Copy pathapp.js
File metadata and controls
112 lines (85 loc) · 1.55 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
// this is a single line comment
//
/* this
* is
* a
* awesome
* multiline
* comment
*/
var a = 3;
var b = 2;
var c = a + b;
console.log('this is a string');
console.log(a);
console.log(b);
console.log(c);
var first = "sally";
var last = 'smith';
var fullName = first + ' ' + last;
console.log(first);
console.log(last);
console.log(fullName);
var d = Math.pow(2, 8);
console.log('2^8 ===', d);
a = 3;
b = 4;
c = 5;
d = 6;
console.log(Math.pow((((a+b)/(b-c))*((b-a)/(c-d))), (b + a)));
// branching with if/else statements
//
var age = 4;
if(age >= 21){
console.log("you are legal to drink");
}else{
console.log('you are not legal to drink');
}
//this is the maximum allowed rating you can see
if(age >= 0 && age <= 5){
console.log('G rated');
}else if(age <= 12){
console.log('PG rated');
}else if(age <= 16){
console.log('PG-13 rated');
}else if(age === 17){
console.log('R rated');
}else if(age === 18){
console.log('NC-17 rated');
}else{
console.log('X rated');
}
var color = 'clue';
switch(color){
case 'green':
console.log('i see green');
break;
case 'blue':
console.log('i see blue');
break;
case 'orange':
console.log('i see orange');
break;
case 'pink':
console.log('i see pink');
break;
case 'black':
console.log('i see black');
break;
default:
console.log('that is not a valid color');
}
// while loop
//
a = 1;
while(a < 10){
console.log('a is looping...', a);
//a++;
// a = a + 1;
a += 2;
}
// for loop
//
for(var i = 0; i < 10; i++){
console.log('i ===', i);
}