https://github.com/lestoni/star-ratings
Calculate weighted average of votes to get a rating
https://github.com/lestoni/star-ratings
Last synced: about 1 year ago
JSON representation
Calculate weighted average of votes to get a rating
- Host: GitHub
- URL: https://github.com/lestoni/star-ratings
- Owner: lestoni
- License: other
- Created: 2016-11-01T14:08:03.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-01T14:21:11.000Z (over 9 years ago)
- Last Synced: 2024-04-24T21:43:39.041Z (about 2 years ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Star Rating
[](https://nodei.co/npm/star-ratings/)
Calculate the Weighted Average to get a rating. Useful for calculating 5-star or more ratings
## example
```javascript
var starRatings = require('star-ratings');
// [1-star-voters, 2-star-voters, 3-star-voters, 4-star-voters, ...]
var votes = [12, 234, 456, 767, 566];
var rating = starRatings(votes);
console.log(rating); // '3.8'
```
## API.
### starRatings(voters#Array)
Returns a `string` _rating_ that is the weighted average.
## install
```javascript
$ npm install star-ratings
```
## license
MIT.