[Javascript] help with array script

BEKIM BACAJ trojani2000 at hotmail.com
Sun Feb 23 14:28:33 CST 2003


See and try to copy-paste the errorfree 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','September','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+ "." +'<BR>');
document.write("Climatic Details in Gove for the month of: " + months 
+'<BR>');
document.write("Max Temp " + now.getMonth()+'<BR>');
document.write("Min Temp " + mintemps + now.getMonth()+'<BR>');
document.write("Monthly Rainfall "+ monthlyrain + 
now.getMonth()+'</B><BR>');

//--></SCRIPT>
Regards!





>From: "Steve Snow" <sjsnow at ozconnect.net>
>Reply-To: javascript at LaTech.edu
>To: "Javascript List" <javascript at LaTech.edu>
>Subject: [Javascript] help with array script
>Date: Sat, 22 Feb 2003 11:57:10 +0930
>
>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.
>
>
>
>
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript


_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail




More information about the Javascript mailing list