I came across a post on reddit, Javagony for Javascript? this morning and thought I'd have to give it a go:
const printSong = bottles => { isFinite(1/(bottles -1)) && console.log(`${bottles.toString()} bottles of beer on the wall,\n${bottles.toString()} bottles of beer!\nTake on down,\nPass it around,`) isFinite(1/(bottles -1)) && bottles-- console.log(`${bottles.toString()} bottles of beer on the wall,`) isFinite(1/(bottles -1)) && printSong(bottles) !isFinite(1/(bottles -1)) && console.log(`${bottles.toString()} bottle of beer on the wall,\n${bottles.toString()} bottle of beer!\nTake on down,\nPass it around,\nNo more bottles of beer on the wall!`) } printSong(99)
I'll keep an eye on other puzzles - the Blackjack one will likely keep me busy too!
No comments:
Post a Comment