iT邦幫忙

2023 iThome 鐵人賽

DAY 29
0
Software Development

LELECOCODE 每一天系列 第 29

Day 29 : Leetcode 小挑戰,30 Days of JavaScript

  • 分享至 

  • xImage
  •  

Day 29: Array Wrapper

Create a class ArrayWrapper that accepts an array of integers in its constructor. This class should have two features:

When two instances of this class are added together with the + operator, the resulting value is the sum of all the elements in both arrays.
When the String() function is called on the instance, it will return a comma separated string surrounded by brackets. For example, [1,2,3].

var ArrayWrapper = function(nums) {
    
};

Example 1:
Input: nums = [[1,2],[3,4]], operation = "Add"
Output: 10

Example 2:
Input: nums = [[23,98,42,70]], operation = "String"
Output: "[23,98,42,70]"

Example 3:
Input: nums = [[],[]], operation = "Add"
Output: 0



上一篇
Day 28 : Leetcode 小挑戰,30 Days of JavaScript
下一篇
Day 30 : Leetcode 小挑戰,30 Days of JavaScript
系列文
LELECOCODE 每一天30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言