mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 14:57:08 +00:00
Time: 48 ms (83.37%), Space: 49.2 MB (97.22%) - LeetHub
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @param {number[]} nums
|
||||
* @return {void}
|
||||
*/
|
||||
var ArrayWrapper = function(nums) {
|
||||
this.nums = nums
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
ArrayWrapper.prototype.valueOf = function() {
|
||||
return this.nums.reduce((a,b) => a + b, 0)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
ArrayWrapper.prototype.toString = function() {
|
||||
return JSON.stringify(this.nums)
|
||||
}
|
||||
|
||||
/**
|
||||
* const obj1 = new ArrayWrapper([1,2]);
|
||||
* const obj2 = new ArrayWrapper([3,4]);
|
||||
* obj1 + obj2; // 10
|
||||
* String(obj1); // "[1,2]"
|
||||
* String(obj2); // "[3,4]"
|
||||
*/
|
||||
Reference in New Issue
Block a user