class ArrayWrapper { nums: number[] = []; constructor(nums: number[]) { this.nums = nums; } valueOf(): number { return this.nums.reduce((s, e) => s += e, 0); } toString(): string { return JSON.stringify(this.nums); } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter