Skip to content

damianc/prod-sum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

prod-sum

Getting a sum and a product.

  • Math.sum(numbers, mapper?)
  • Math.prod(numbers, mapper?)
Math.sum([1,2,3,4])
// 10

Math.prod([1,2,3,4])
// 24
// sum of squares

Math.sum([1,2,3,4], x => x**2)
// 1^2 + 2^2 + 3^2 + 4^2
// 30
function hypot(...args) {
  return Math.sqrt(
    Math.sum(args, x => x**2)
  );
}

hypot(1,2,3,4)
// 5.47722558

Math.hypot(1,2,3,4)
// 5.47722558

About

Getting a sum and a product.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published