Created
September 25, 2012 20:21
-
-
Save Hupotronic/3784206 to your computer and use it in GitHub Desktop.
Star-tastic, Gotta Go Fast edition.
This file contains 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
// Convert a floating point 0-5 average to a "star" array (0 = none, 1 = half, 2 = full) | |
var stars = function(x) { | |
var i=0,k=0,a=[],r=~~(x*2+.5); | |
while(k<5)a[k++]=r<++i?0:r>i++?2:1; | |
return a; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment