First commit of partial RosettaCode contents.
Pushing this for testing purposes. Lots of work still needed.
This commit is contained in:
commit
1e05ecd7ee
781 changed files with 9080 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
// Line breaks are in HTML
|
||||
var beer; while ((beer = typeof beer === "undefined" ? 99 : beer) > 0) document.write( beer + " bottle" + (beer != 1 ? "s" : "") + " of beer on the wall<br>" + beer + " bottle" + (beer != 1 ? "s" : "") + " of beer<br>Take one down, pass it around<br>" + (--beer) + " bottle" + (beer != 1 ? "s" : "") + " of beer on the wall<br>" );
|
||||
21
Task/99_Bottles_of_Beer/JavaScript/99_bottles_of_beer-3.js
Normal file
21
Task/99_Bottles_of_Beer/JavaScript/99_bottles_of_beer-3.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Line breaks are in HTML
|
||||
function Bottles(count){
|
||||
this.count = (!!count)?count:99;
|
||||
this.knock = function(){
|
||||
var c = document.createElement('div');
|
||||
c.id="bottle-"+this.count;
|
||||
c.innerHTML = "<p>"+this.count+" bottles of beer on the wall</p>"
|
||||
+"<p>"+this.count+" bottles of beer!</p>"
|
||||
+"<p>Take one down,<br>Pass it around</p>"
|
||||
+"<p>"+(--this.count)+" bottles of beer on the wall</p><p><br></p>";
|
||||
document.body.appendChild(c);
|
||||
}
|
||||
this.sing = function(){
|
||||
while (this.count>0) { this.knock(); }
|
||||
}
|
||||
}
|
||||
|
||||
(function(){
|
||||
var bar = new Bottles(99);
|
||||
bar.sing();
|
||||
})();
|
||||
18
Task/99_Bottles_of_Beer/JavaScript/99_bottles_of_beer-4.js
Normal file
18
Task/99_Bottles_of_Beer/JavaScript/99_bottles_of_beer-4.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
function bottleSong(n) {
|
||||
if (!isFinite(Number(n)) || n == 0) n = 100;
|
||||
var a = '%% bottles of beer',
|
||||
b = ' on the wall',
|
||||
c = 'Take one down, pass it around',
|
||||
r = '<br>'
|
||||
p = document.createElement('p'),
|
||||
s = [],
|
||||
re = /%%/g;
|
||||
|
||||
while(n) {
|
||||
s.push((a+b+r+a+r+c+r).replace(re, n) + (a+b).replace(re, --n));
|
||||
}
|
||||
p.innerHTML = s.join(r+r);
|
||||
document.body.appendChild(p);
|
||||
}
|
||||
|
||||
window.onload = bottleSong;
|
||||
10
Task/99_Bottles_of_Beer/JavaScript/99_bottles_of_beer.js
Normal file
10
Task/99_Bottles_of_Beer/JavaScript/99_bottles_of_beer.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Line breaks are in HTML
|
||||
var beer = 99;
|
||||
while (beer > 0)
|
||||
{
|
||||
document.write( beer + " bottles of beer on the wall<br>" );
|
||||
document.write( beer + " bottles of beer<br>" );
|
||||
document.write( "Take one down, pass it around<br>" );
|
||||
document.write( (beer - 1) + " bottles of beer on the wall<br>" );
|
||||
beer--;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue