Scott Scharl

Husband, Dad, Web Developer

JavaScript function that builds a progress bar using emojis

function getProgressBar(numerator: number, denominator: number) { const percentage = Math.round((numerator / denominator) * 100); const tenths = Math.round(percentage / 10); const barTenths = [ '⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️', '🟦⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️', '🟦🟦⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️', '🟦🟦🟦⬜️⬜️⬜️⬜️⬜️⬜️⬜️', '🟦🟦🟦🟦⬜️⬜️⬜️⬜️⬜️⬜️', '🟦🟦🟦🟦🟦⬜️⬜️⬜️⬜️⬜️', '🟦🟦🟦🟦🟦🟦⬜️⬜️⬜️⬜️', '🟦🟦🟦🟦🟦🟦🟦⬜️⬜️⬜️', '🟦🟦🟦🟦🟦🟦🟦🟦⬜️⬜️', '🟦🟦🟦🟦🟦🟦🟦🟦🟦️⬜️', '🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩', ]; return barTenths[tenths]; };