Warping it up!

Fini Alring's Glossy Tech Zine

99 Bottles

I decided it was time to finally post some of my code on this fancy blog of mine, enjoy or retreat 😉 This first codepost is one I made for www.99-bottles-of-beer.net, because I thought the existing JavaScript / ECMAScript contribution sucked in terms of showing any capabilities of the language, was more or less a conversion from BASIC. I called it Wildstyle because it definately does not conform to my usual style of coding, and is of course just made purely for the fun of it..

/*
* 99 Bottles of Beer in JavaScript / ECMAScript (Wildstyle)
* This program prints out the lyrics of an old pub song.
* Written by Fini A. Alring (alring@bytefarmers.com) in 2003
* Use it as you wish, especially suited for killing time at nuclear plants.
*/

var b, b2, o, o2, t;
var t2 = ” of beer on the wall”;
var t3 = “bottle”
var t4 = “Take 1 down, pass it around, “;
var t5 = “No more ”

for (b = 99, b2 = b – 1; b > 0; b–, b2 = b – 1) {

o = t3;
(b == 1) ? 1 : o+=’s’ ;

o2 = o.substr(0,6);
(b2 == 1) ? 1 : o2+=’s’

t = b + ” ” + o + t2 + “, ” + b + ” ” + o + t2.substr(0,8) + “, ” + t4;
(b2 != 0) ? (t += b2 + ” ” + o2 + ” ” + t2 + “.”) : (t += t5 + o + “s” + t2 + “!”) ;

document.writeln(t + ‘<br/>’);
}

Next up: Running the code…
grab the source here