[Javascript] help with array script
Steve Snow
sjsnow at ozconnect.net
Fri Feb 21 20:27:10 CST 2003
I am getting an error in the last line of the "document.write"
Here is the script
<p> <SCRIPT LANGUAGE="Javascript"><!--
// Get today's current date.
var now = new Date();
// Array list of days.
var days = new
Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'
);
// Array list of months.
var months = new
Array('January','February','March','April','May','June','July','August','Sep
tember','October','November','December');
// Array list of max temps.
var maxtemps=new
array('32.4','32.5','31.5','30.1','29,2','28.3','26.5','27.7','29.2','31.1',
'33.1','33.2');
// Array list of min temps.
var mintemps=new
array('25.2','25,1','24.2','23.3','21.1','20.1','19.6','19.2','21.1','23.2',
'24.2','25.0');
// Array list of monthly rainfall data
var monthlyrain=new
array('294.6','300.1','320.0','189.9','89.2','23.2','21.0','15.8','7.8','3.6
','14.4','198.0');
// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
// Calculate four digit year.
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;
}
// Join it all together
today = days[now.getDay()] + ", " +
months[now.getMonth()] + " " +
date + ", " +
(fourdigits(now.getYear())) ;
// Print out the data.
document.write(<b>"Today\'s date is " +today+ "."</b>);
document.write(<b>"Climatic Details in Gove for the month of " +months</b>)
document.write(<b>"Max Temp " +maxtemps(now.getMonth()</b>);
document.write(<b>"Min Temp " +mintemps(now.getMonth()</b>);
document.write(<b>"Monthly Rainfall "+monthlyrain(now.getMonth()</b>);
//--></SCRIPT>
The output should be: (all lines bolded)
Today's date is Saturday February 22, 2003 (this line works fine before
adding the maxtemps, mintemps, monthlyrain arrays)
Max Temp 32.5
Min Temp 25.1
Monthly Rainfall 300.1
I would appreciate any assistance. Thanks.
More information about the Javascript
mailing list