KendallDoesCoding / mogul-christmas

Prefer var declarations be placed at the top of their scope JS-0102
Anti-pattern
Minor
a year agoa year old
All 'var' declarations must be at the top of the function scope.
14var days = 0;
15
16// Update the count down every 1 second
17var x = setInterval(function() {1819  // Get today's date and time20   now = new Date().getTime();2122  // Find the distance between now and the count down date23  distance = countDownDate - now;2425  // Time calculations for days,26 days = Math.floor(distance / (1000 * 60 * 60 * 24));272829  // Display the result in the element with id="demo"3031  document.getElementById("christmasDayCountdown").innerHTML = days + " days left until Christmas " ;3233  // If the count down is finished, write some text34  if (distance < 0) {35    clearInterval(x);36    document.getElementById("christmasDayCountdown").innerHTML = "";37  }38}, 1000);39
40// // days since christmas was OVER
41
All 'var' declarations must be at the top of the function scope.
10/*Christmas day countdown  */
11var countDownDate = new Date("Dec 25, 2023 23:59:59").getTime();
12var now = 0;
13var distance =0;14var days = 0;
15
16// Update the count down every 1 second
All 'var' declarations must be at the top of the function scope.
 8}
 9
10/*Christmas day countdown  */
11var countDownDate = new Date("Dec 25, 2023 23:59:59").getTime();12var now = 0;
13var distance =0;
14var days = 0;
All 'var' declarations must be at the top of the function scope.
 9
10/*Christmas day countdown  */
11var countDownDate = new Date("Dec 25, 2023 23:59:59").getTime();
12var now = 0;13var distance =0;
14var days = 0;
15
All 'var' declarations must be at the top of the function scope.
11var countDownDate = new Date("Dec 25, 2023 23:59:59").getTime();
12var now = 0;
13var distance =0;
14var days = 0;15
16// Update the count down every 1 second
17var x = setInterval(function() {