Usage: Assign the function to something, eg. var stars = function(a,b,c,d){ ... }
The function takes a floating point value and turns it into a "star" array. For example:
stars(2.5) => [2,2,1,0,0]
stars(3.8) => [2,2,2,2,0]
In these arrays, 2 = full star, 1 = half-star, 0 = no star. The function also takes an optional second argument which you can use to determine the amount of stars (default is 5). Like so:
stars(7.4,10) => [2,2,2,2,2,2,2,1,0,0,0]
This function can be useful if you want to display a star rating where each star is an individual element and you want half-stars as well.
I'd say trying to render the stars inside the function and returning that would be a lot less useful than the array it returns at the moment. Though if Unicode had a "half-star" glyph making the function return a star string instead would be easy...