Created
September 17, 2023 03:51
-
-
Save higby/5f679ad86b4a36163edf0eb4205724c1 to your computer and use it in GitHub Desktop.
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
function star(input) { | |
if (typeof input !== 'number') throw new Error(`Requires number`) | |
let stars = '' | |
let floor = Math.floor(input) | |
for (let i = 0; i < floor; i++) stars += '★' | |
if (input - floor == 0.5) stars += '½' | |
return stars | |
} | |
star(4.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment