-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex03.js
47 lines (43 loc) · 1.22 KB
/
index03.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
var neo =
{
age:NaN,
canJump:false,
wakeUp:true,
greetings:function() {console.log('age: '+this.age+' can jump: '+this.canJump+' was waked up: '+this.wakeUp);}
}
var morpheus = {};
morpheus.age=99;
morpheus.canJump=true;
morpheus.wakeUp=false;
morpheus.greetings= function(){console.log('age: '+this.age+' can jump: '+this.canJump+' was waked up: '+this.wakeUp);}
console.log(neo);
console.log(morpheus);
neo.greetings();
morpheus.greetings();
/* - =============== - method 2 */
console.log('* method 2 *');
/* - =============== - method 2 */
var matrixman = function(age,canJump,wakeUp)
{return {age:age, canJump:canJump,wakeUp:wakeUp,greetings:function()
{console.log('age: '+this.age+' can jump: '+this.canJump+' was waked up: '+this.wakeUp);}}
}
neo2 = matrixman(23,false,true);
morpheus2 = matrixman(48,true,false);
console.log(neo2);
console.log(morpheus2);
neo2.greetings();
morpheus2.greetings();
function average () {
var quantity=0;
var total=0;
for (var i in arguments)
{
if (typeof(arguments[i])=='number') {
total+=arguments[i];
quantity++;
}
}
console.log(arguments);
return total/quantity;
}
console.log(average(1,2,3,4,5,6,7,8,9,'pupkin',14,33,'tadaaa'));