Skip to content

Commit 076b49d

Browse files
day 29 task complete
1 parent 3d55bc4 commit 076b49d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

day29/leetcode2695.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)