/** * @projectDescription Javascript snippet to generate the lyrics of the song "99 Bottles". * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com * Date: 3/27/2008 * @author Ariel Flesler * --This script follows the standard specified by scriptDoc: http://scriptdoc.org/ */ /** * @classDescription This class generates the lyrics of the song "99 Bottles". * @return { Song } Returns a new Song Object. * @constructor */ var Song = function(){}; //add methods to the prototype, to affect the instances of the class Song Song.prototype = { /** * Maps an array of items using a function. * @param { Array } src Source array whose items will be mapped. * @param { Function } fn Function that receives each item & index and returns the mapped item. * @return { Array } The mapped array. * @method * http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:map */ map: function( src, fn ){ var mapped = [ ], //will hold the mapped items pos = src.length; //holds the actual index //do a reversed loop as we know the last index while( pos-- ) mapped[pos] = fn.call( this, src[pos], pos ); return mapped; }, /** * @param { Number } amount Specifies the # of bottle. * @return { S