Skip to content

Instantly share code, notes, and snippets.

@jordangarcia
Created June 21, 2019 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordangarcia/63372c9840cefd2be99fa6fa24c6f346 to your computer and use it in GitHub Desktop.
Save jordangarcia/63372c9840cefd2be99fa6fa24c6f346 to your computer and use it in GitHub Desktop.
function ninetyNineBottles(num) {
if (num === 0) {
console.log(`No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.`);
return;
} else if (num > 2) {
console.log(`${num} bottles of beer on the wall, ${num} bottles of beer.
Take one down and pass it around, ${num - 1} bottles of beer on the wall.`);
} else if (num === 2) {
console.log(`2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.`);
} else if (num === 1) {
console.log(`1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.`);
}
ninetyNineBottles(num - 1);
}
`99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.`;
ninetyNineBottles(99);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment