// generic JS code file function doMain () { // there are several ways to use functions /* 1. A function can take simple variable input parameters and return a value that is needed in the part of the program calling the function */ var res; var num = 25; res = Math.sqrt(num); alert(res); alert(doMasher(num)); res = 3 * doMasher(4); alert(res); /* 2. A function can take simple variable input parameters and return no value so the program calling the function is not expecting any value coming back */ showStats(num); /* 3. A function can take array input parameters and thereby make changes in the part of the program calling the function using the array(s) It may also directly return a value, or not. */ var i, big; var numbers = new Array(6); for (i=0; iParameter value times 5 is "+val*5 + ""); } function findBiggie( arr ) { var k; var res = 0; for (k=0; kres) { res = arr[k]; } } return res; } function bubbleBiggie( arr ) { var k; var tmp; for (k=0; karr[k+1]) { tmp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = tmp; } } } function showArray ( arr ) { var k; document.write("

array values

"); for (k=0; k"+arr[k]); } }