Skip to main content

2695. Array Wrapper

https://leetcode.com/problems/array-wrapper

Javascript

var ArrayWrapper = function(nums) {
this.nums = nums
};

ArrayWrapper.prototype.valueOf = function() {
return this.nums.reduce((accu, num) => num+accu, 0)
}

ArrayWrapper.prototype.toString = function() {
return JSON.stringify(this.nums)
}