Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/damianc/prod-sum
Getting a sum and a produkt.
https://github.com/damianc/prod-sum
Last synced: about 1 month ago
JSON representation
Getting a sum and a produkt.
- Host: GitHub
- URL: https://github.com/damianc/prod-sum
- Owner: damianc
- Created: 2024-03-15T22:24:14.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-03-15T22:47:30.000Z (10 months ago)
- Last Synced: 2024-03-15T23:34:19.934Z (10 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# prod-sum
Getting a sum and a product.
- `Math.sum(numbers, mapper?)`
- `Math.prod(numbers, mapper?)````
Math.sum([1,2,3,4])
// 10Math.prod([1,2,3,4])
// 24
``````
// sum of squaresMath.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.47722558Math.hypot(1,2,3,4)
// 5.47722558
```