We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3d55bc4 commit 076b49dCopy full SHA for 076b49d
day29/leetcode2695.js
@@ -0,0 +1,32 @@
1
+// 2695. Array Wrapper
2
+// URL -> https://leetcode.com/problems/array-wrapper/
3
+
4
+/**
5
+ * @param {number[]} nums
6
+ * @return {void}
7
+ */
8
+var ArrayWrapper = function (nums) {
9
+ this.arr = nums
10
+};
11
12
13
+* @return {number}
14
+*/
15
+ArrayWrapper.prototype.valueOf = function () {
16
+ return this.arr.reduce((acc, curr) => acc + curr, 0)
17
+}
18
19
20
+* @return {string}
21
22
+ArrayWrapper.prototype.toString = function () {
23
+ return JSON.stringify(this.arr)
24
25
26
27
+* const obj1 = new ArrayWrapper([1,2]);
28
+* const obj2 = new ArrayWrapper([3,4]);
29
+* obj1 + obj2; // 10
30
+* String(obj1); // "[1,2]"
31
+* String(obj2); // "[3,4]"
32
0 commit comments