I'm new to JavaScript, and I need some help figuring out this problem. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I'm new to JavaScript, and I need some help figuring out this problem.

i keep getting a variable declaration error on the thisTime variable, but after many tries i have been unable to fix it so i am asking for some insights. "Sky Map Variable Next, you will determine which sky map to show in the web page. First, create a variable named thisHour, using the getHours() method to extract the hour value from the thisTime variable. Create a variable named thisMonth using the getMonth() method to extract the month number from the thisTime variable. The number of the map to use with the given hour and month is calculated with the formula (2×month + hour) % 24 where month is the value of the thisMonth variable and hour is the value of the thisHour variable. Store the value of this formula in the mapNum variable." My code. /* set new date */ thisTime= Date (February 3, 2018 03:15:28 AM ); timeStr = thisTime.toLocaleString(); document.getElementById("thisStamp").innertHTML=timeStr; /* time varaibles */ var thisHour = thisTime.getHours(); var thisMonth = thisTime.getMonth(); var mapNum = ((2* thisMonth + thisHour )%24); var imgStr = "<img src='sd_sky" + mapNum + " .png' />"; document.getElementById("planisphere").insertAdjacentHTML('afterBegin',imgStr);

30th Mar 2020, 4:00 AM
Esvin
1 Answer
+ 2
You've a mispelling in the first assignation (implicit declaration) of your "thisTime" variable (missing final "e") ^^
30th Mar 2020, 6:41 AM
visph
visph - avatar