ga-dc / wdi5

wdi dc 5
10 stars 34 forks source link

w10d05 quiz #51

Closed janicemin closed 9 years ago

janicemin commented 9 years ago

Write program that prints out lyrics of 99 bottles of beer on the wall.

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

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

for(var counter = 100; counter--;) { var Num = counter+''; var output = ''; if(counter>19) { output = ten[Num[0]]; output += (Num[1]==0) ? '' : '-'+single[Num[1]].toLowerCase(); } else { output = single[counter]; }

output += (counter==1) ? ' bottle' : ' bottles';
output += ' of beer on the wall.';
console.log(output);

}