We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dd7356c commit d26239eCopy full SHA for d26239e
JavaScript/2-middle.js
@@ -0,0 +1,31 @@
1
+'use strict';
2
+
3
+const adder = initial => ({
4
+ value: initial,
5
+ add(value) {
6
+ this.value += value;
7
+ return this;
8
+ }
9
+});
10
11
+const Adder = class {
12
+ constructor(initial) {
13
+ this.value = initial;
14
15
16
17
18
19
+};
20
21
+// Usage
22
23
+{
24
+ const v = new Adder(3).add(-9).add(12);
25
+ console.log(v);
26
+}
27
28
29
+ const v = adder(3).add(-9).add(12);
30
31
0 commit comments