Language JavaScript
Date: | 04/20/05 |
Author: | Brian Patrick Lee |
URL: | n/a |
Comments: | 3 |
Info: | n/a |
Score: | (2.75 in 24 votes) |
/** * 99 Bottles of Beer on the Wall in JavaScript * This program prints out the lyrics of an old pub song. * Copyright (C) 1996, Brian Patrick Lee (blee@media-lab.mit.edu) */ if (confirm("Are you old enough to read about beer\n" + "according to your local community standards?")) { for (i = 99 ; i > 0 ; i--) { j = i - 1; if (i != 1) { icase = "bottles"; } else { icase = "bottle"; } if (j != 1) { jcase = "bottles"; } else { jcase = "bottle"; } document.writeln(i + " " + icase + " of beer on the wall,"); document.writeln(i + " " + icase + " of beer,"); document.writeln("Take 1 down, pass it around,"); if (j != 0) { document.writeln(j + " " + jcase + " of beer on the wall."); } else { document.writeln("No more bottles of beer on the wall!"); } document.writeln() } } else { document.write("You might want think about moving to another community.") }
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
Eponymous obfuscated version | JavaScribe | 01/09/09 | 4 | |
Fully commented, OOP approach. | Ariel Flesler | 03/28/08 | 0 | |
using DOM and a closure | Christof Donat | 03/07/06 | 0 | |
With english numbers, DOM, and callbacks | Joseph Taylor | 01/18/08 | 0 |
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
Koni Joto said on 06/15/05 14:46:35
But what's about <br>s? The text looks ugly.
Nox said on 01/18/06 17:29:31
I was just reading a website about "Obfuscated Programming". So here is my 15 minute work =)
Simply Copy&Paste into a HTML. Testet with newest FF.
<script>var _=[' bottle',' of beer',' on the wall','Take one down, pass it around','If one of those bottles should happen to fall','Go to the store and buy some more.','No more '];document.writeln({$:function(_){var __='';if(_ instanceof Array)for(var $$ in _)__+=this.$(_[$$])+'<br>';return __||_;},$_:function(n){var $$=this.$(n?[n+_[0]+(n==1?'':'s')+_[1]+_[2],n+_[0]+(n-1?'s':'')+_[1]+'!',(n-1?_[3]:_[4]),n-1?(n+_[0]+(n==1?'':'s')+_[1]+_[2]+'!'):(_[6]+_[0]+'s'+_[1]+_[2]+'!'),'']:[_[6]+_[0]+'s'+_[1]+_[2],_[6]+_[0]+'s'+_[1]+'!',_[5],99+_[0]+'s'+_[1]+_[2]+'!']);if(n--){$$+=this.$_(n);}return $$;}}['$_'](99));</script>
toxik said on 02/12/06 03:01:12
Damnit, read the lyrics and produce them exactly as they should be.
(refering to the end espec.)