-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (35 loc) · 1.14 KB
/
index.js
File metadata and controls
39 lines (35 loc) · 1.14 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
const defaultArguments = require("./default.arguments");
function exampleAssert() {
function add(a, b) {
return a + b;
};
const add2 = defaultArguments(add, { b: 9 });
console.assert(add2(10) === 19);
console.assert(add2(10, 7) === 17);
console.assert(isNaN(add2()));
const add3 = defaultArguments(add2, { b: 3, a: 2 });
console.assert(add3(10) === 13);
console.assert(add3() === 5);
console.assert(add3(undefined, 10) === 12);
const add4 = defaultArguments(add, { c: 3 });
console.assert(isNaN(add4(10)));
console.assert(add4(10, 10) === 20);
}
function exampleAssertWithArrow() {
const addArrow = (a, b) => {
return a + b;
}
const add2 = defaultArguments(addArrow, { b: 9 });
console.assert(add2(10) === 19);
console.assert(add2(10, 7) === 17);
console.assert(isNaN(add2()));
const add3 = defaultArguments(add2, { b: 3, a: 2 });
console.assert(add3(10) === 13);
console.assert(add3() === 5);
console.assert(add3(undefined, 10) === 12);
const add4 = defaultArguments(addArrow, { c: 3 });
console.assert(isNaN(add4(10)));
console.assert(add4(10, 10) === 20);
}
exampleAssert();
exampleAssertWithArrow();