Last active
April 13, 2016 03:54
-
-
Save 121onto/f21560b8f25d80d0d2c4c54be99e7c18 to your computer and use it in GitHub Desktop.
Display ratings on a yelp page as an array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get array of ratings | |
var ratings = $("i.star-img") | |
.map(function(){return $(this).attr( "title" )}) | |
.map(function(){return this.split(/[ ,]+/)}) | |
.map(function(){return Number(this)}) | |
.filter(function(){return this >= 0}) | |
.toArray() | |
// print summary stats | |
console.log("LEN: ", ratings.length) | |
console.log("SUM: ", ratings.reduce(function(pv, cv) { return pv + cv; })) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment