I having trouble returning the string in this function. For starters I'm a beginner who just started learn javascript a week ago, sorry in advance if I word things wrong. I was told to declare a variable named timeStr to equal the value returned from the showDate() function as well as mapNum to the getMap() function. Both the showDateTime() and getMap() function are in a file that I'm accessing called datetime.js. I would just like some input on where I made the mistake and how to correct it, thanks.
<script src="datetime.js" type="text/javascript"></script>
<script type="text/javascript">
function test(){
/*
timeStr is a text string containing the current date and time
mapNum is the number of the map to display in the planisphere
/*
var timeStr = showDateTime();
var mapNum = getMap();
}
</script>
UPDATE: The datetime.js is below:
/*
New Perspectives on JavaScript, 2nd Edition
Tutorial 1
Case Problem 1
Function List:
showDate
Used to return a text string containing the current date and time.
getMap
Used to the determine the current sky map number to display with the online planisphere
*/
function showDateTime() {
var thisDate = new Date();
var thisWDay=thisDate.getDay();
var thisDay=thisDate.getDate();
var thisMonth=thisDate.getMonth();
var thisYear=thisDate.getFullYear();
var mName = new Array("January", "February", "March", "April", "May",
"June", "July", "August", "September", "October","November", "December");
var hours=thisDate.getHours();
var minutes=thisDate.getMinutes();
ampm = hours >=12 ? " pm" : " am";
hours = hours > 12 ? hours-12 : hours;
minutes = minutes < 10 ? "0"+minutes : minutes;
return mName[thisMonth]+" "+thisDay+", "+thisYear + ", " + hours + ":" + minutes + ampm;
}
function getMap() {
thisTime = new Date();
hour = thisTime.getHours();
month = thisTime.getMonth();
mapNumber = (month*2+hour)%24;
return mapNumber;
}