Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nhsz/triangle-area
Get the area of a triangle, given the base and height
https://github.com/nhsz/triangle-area
area geometry math nodejs npm npm-package polygons triangle triangle-area
Last synced: 11 days ago
JSON representation
Get the area of a triangle, given the base and height
- Host: GitHub
- URL: https://github.com/nhsz/triangle-area
- Owner: nhsz
- License: mit
- Created: 2017-06-02T20:06:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-03T17:50:59.000Z (over 7 years ago)
- Last Synced: 2024-10-07T17:41:20.656Z (about 1 month ago)
- Topics: area, geometry, math, nodejs, npm, npm-package, polygons, triangle, triangle-area
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/triangles-area
- Size: 47.9 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# triangles-area
[![NPM](https://nodei.co/npm/triangles-area.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/triangles-area/)
> Get the **[`area of a triangle`](https://en.wikipedia.org/wiki/Triangle#Computing_the_area_of_a_triangle)**, given the base and height
## Install
```
$ npm install --save triangles-area
```## Usage
```js
const triangleArea = require('triangles-area')console.log(triangleArea(24, 27.6))
// => 331.2console.log(triangleArea(12, 2.5))
// => 15console.log(triangleArea(11, 13.4))
// => 73.7console.log(triangleArea(0, 78))
// => Error: Invalid input. Sides of the triangle must be greater than 0console.log(triangleArea(1, -1))
// => Error: Invalid input. Sides of the triangle must be greater than 0
```## License
MIT © **[`Nicolás Quiroz`](https://nicolasquiroz.com)**