-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.js
More file actions
187 lines (141 loc) · 2.85 KB
/
start.js
File metadata and controls
187 lines (141 loc) · 2.85 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*var myValue = 'Hello World';
var myNum = 10;
let a = 100;
let b = 200;
const c = 300;
if(a){
console.log(a);
let d = 'Anything';
console.log(d);
}
console.log(d);*/
//console.log(a,b,c);
//let result = prompt('What is your name?');
//console.log(result);
//console.log(document);
//console.dir(document);
/* let myObj={first: "wer", last: "Sort"};
console.log(myObj);
myObj.first='Jol';
console.log(myObj);
let myChair = {color: 'blue', wheels: 4, age: 14}
console.log(myChair);
myObj['second'] = 'second';
let holder = 1;
myObj['a'+holder] ='third';
console.log(myObj);
console.log(document.lastModified);
*/
let myArray = ['Hello', 'World', 50, false];
console.log(myArray);
console.log(myArray[0]+""+myArray[1]);
myArray[myArray.length] = 'New item';
console.log(myArray);
let lastone = myArray.push('At the End');
console.log(lastone);
//myArray.pop();
//console.log(myArray);
//let firstone = myArray.shift();
//console.log(firstone);
/* let rep = myArray.splice();
console.log(rep);
*/
let res = myArray.slice(3);
myArray[3]=true;
console.log(res);
let myStr = myArray.toString();
let myArray2 = myStr.split(',');
let myArray3 = myArray.join('-');
console.log(myStr);
console.log(myArray2);
console.log(myArray3);
let x = 100;
console.log(x+x);
let y = x;
console.log(y);
let a, b, c;
a = 5;
b = c = a + 5;
let num = 0;
testOne(4);
testOne("New");
function testOne(val){
console.log(val);
let hello = val + "Hello world";
num++;
console.log(hello + num);
return hello;
}
function test4(x, y = 10){
console.log(x);
console.log(y);
return x*y;
}
console.log(test4(5));
console.log(test4(5,7));
let myFun1 = function(x=10){
return x*10
}
function myFun2(x=10){
return x*10;
}
let myFun3 = (x=10) => x*10;
myFun5(3,566,6,99);
function myFun5(a,b=2,c=9){
console.log(arguments.length);
console.log(arguments[1]);
}
let messages = {
welcome : ['Welcome first','Welcome second'],
hello:function(){
console.log('Hello how are you');
},
goodbye:function(){
console.log('Thanks for coming Bye now');
},
output:function(mes){
console.log(mes);
}
}
let k = 5;
let l = 55;
if(k>3 || l<3){
console.log('k has a value');
}
if(k){
console.log('k has a value');
}
if(l>10){
console.log('l has a value');
}
if(0){
console.log('falsy');
}
if(1){
console.log('truthy');
}
if(l>10 && l<30){
console.log('l between 10 and 30');
}else if (k>1 && k<10){
console.log('k between 1 and 10');
}else{
console.log('None were true');
}
if(0){
console.log('falsy');
}else{
console.log('was a falsy');
}
let e;
if (k>10){
e="YES";
}
else{
e="NO";
}
let d = (k>10)?"YES":"NO";
console.log(e,d);
let age = Number(prompt('How old are you?'));
console.log(typeof age);
let ofAge = age > 18 ?"True can drink":"Under age";
console.log(ofAge);