code.ashish.me

Atom feed

Recently added: 02 Count Of Subset Sum, 416 Partition Equal Subset Sum, 01 Subset Sum, 518 Coin Change 2, 983 Minimum Cost For Tickets

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:35:16+05:18 · Edit