-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path2-sync.js
More file actions
46 lines (36 loc) · 780 Bytes
/
2-sync.js
File metadata and controls
46 lines (36 loc) · 780 Bytes
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
'use strict';
function inc(a) {
return a + 1;
}
const sum = function (a, b) {
return a + b;
};
const max = (a, b) => (a > b ? a : b);
const avg = (a, b) => {
const s = sum(a, b);
return s / 2;
};
const obj = {
name: 'Marcus Aurelius',
split(sep = ' ') {
return this.name.split(sep);
},
};
class Person {
constructor(name) {
this.name = name;
}
static of(name) {
return new Person(name);
}
split(sep = ' ') {
return this.name.split(sep);
}
}
const person = Person.of('Marcus Aurelius');
console.log('inc(5) =', inc(5));
console.log('sum(1, 3) =', sum(1, 3));
console.log('max(8, 6) =', max(8, 6));
console.log('avg(8, 6) =', avg(8, 6));
console.log('obj.split() =', obj.split());
console.log('person.split() =', person.split());