This old man
demonstrates functions
Source code
function main(){
verse1();
chorus();
verse2();
chorus();
} // end main
function chorus(){
var theSong = "..with a knick-knack \n";
theSong += "paddy-whack\n";
theSong += "give a dog a bone...\n";
theSong += "\n This old man came rolling home \n";
alert (theSong);
} // end chorus
function verse1(){
var theSong = "This old man, \n";
theSong += "He played one. \n";
theSong += "He played knick-knack \n";
theSong += "on my thumb... \n";
alert(theSong);
} // end verse1
function verse2(){
var theSong = "This old man, \n";
theSong += "He played two. \n";
theSong += "He played knick-knack \n";
theSong += "on my shoe... \n";
alert(theSong);
} // end verse1
Andy Harris