code.ashish.me

Atom feed

Recently added: 128 Longest Consecutive Sequence, 347 Top K Frequent Elements, 045 Jump Game 2, 228 Summary Ranges, 219 Contains Duplicate 2

002 Add

/**
 * 
 * Ashish Patel
 * e: ashishsushilPatel@gmail.com
 * w: https://ashish.me
 *
 */

// Write a function that returns the sum of all numbers regardless of # of params.

function add(...args) {
  return args.reduce((i, sum) => i + sum)
}

test('add', () => {
  expect(add([2,3])).toEqual(5)
});

Created 2019-12-05T02:47:16+05:30 · Edit