JSFiddle - React, Tailwind, and code Playground

by dawnerd

HTML

To view, inspect this result pane.

JavaScript

var singles = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'];

var tens = ['','','Twenty', 'Thirty', 'Fourty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'];

for(var counter = 100; counter--;) {
  var tmpNum = counter+'';
  var output = '';
  if(counter>19) {
    output = tens[tmpNum[0]];
    output += (tmpNum[1]==0) ? '' : '-'+singles[tmpNum[1]].toLowerCase();
  } else {
    output = singles[counter]; 
  }
    
    output += (counter==1) ? ' bottle' : ' bottles';
    output += ' of beer on the wall.';
    console.log(output);
}