From 3bfdc2a26b1aa079688250c73ce18ea889f443dc Mon Sep 17 00:00:00 2001 From: Yuya Minamide Date: Sun, 4 Jun 2023 17:21:31 -0700 Subject: [PATCH 1/2] solved 2703. Return Length of Arguments Passed --- 2703.return-length-of-arguments-passed.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 2703.return-length-of-arguments-passed.js diff --git a/2703.return-length-of-arguments-passed.js b/2703.return-length-of-arguments-passed.js new file mode 100644 index 0000000..01a75ba --- /dev/null +++ b/2703.return-length-of-arguments-passed.js @@ -0,0 +1,15 @@ +/** + * URL of this problem + * https://leetcode.com/problems/return-length-of-arguments-passed/ + */ + +/** + * @return {number} + */ +var argumentsLength = function (...args) { + return [...args].length; +}; + +/** + * argumentsLength(1, 2, 3); // 3 + */ From 226b1df09a065e39e2b192e2a3ee52d9905f755b Mon Sep 17 00:00:00 2001 From: Yuya Minamide Date: Sun, 4 Jun 2023 17:22:54 -0700 Subject: [PATCH 2/2] solved 2695. Array Wrapper --- 2695.array-wrapper.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 2695.array-wrapper.js diff --git a/2695.array-wrapper.js b/2695.array-wrapper.js new file mode 100644 index 0000000..c671858 --- /dev/null +++ b/2695.array-wrapper.js @@ -0,0 +1,27 @@ +/** + * URL of this problem + * https://leetcode.com/problems/array-wrapper/ + */ + +/** + * @param {number[]} nums + */ +var ArrayWrapper = function (nums) { + this.nums = nums; +}; + +ArrayWrapper.prototype.valueOf = function () { + return this.nums.reduce((acc, cur) => acc + cur, 0); +}; + +ArrayWrapper.prototype.toString = function () { + return "[" + this.nums.toString() + "]"; +}; + +/** + * const obj1 = new ArrayWrapper([1,2]); + * const obj2 = new ArrayWrapper([3,4]); + * obj1 + obj2; // 10 + * String(obj1); // "[1,2]" + * String(obj2); // "[3,4]" + */