I’m trying to create a Countdown Timer mäbut I have some issues in the coding process. Can someone tell me why the console is telling me 'Uncaught SyntaxError: Missing initializer in const declaration ’ plus give me an idea on what I could code. My js. And html code is below
Javascript:
const days[] = document.getElementById('days')
const hours[] = document.getElementById('hours')
const minutes[] = document.getElementById('minutes')
const seconds[] = document.gwtElementById('seconds')
const newYears = '1 Jan 2021';
function countdown () {
const newYearsDate = new Date(newYears);
const currentDate = new date ();
const seconds = (newYearsDate - currentDate) / 1000;
const days = Math.floor(totalSeconds / 3600 / 24);
const hours = Math.floor(totalSeconds / 3600) % 24;
const minutes= Math.floor(totalSeconds / 60) % 60;
const seconds = Math.floor(totalSeconds) % 60;
console.log(newYearsDate - currentDate)
days[].innerHTML = days;
hours[].innerHTML = hours;
minutes[].innerHTML = minutes;
seconds[].innerHTML = seconds;
}
countdown()
setInterval(countdown, 1000)
Html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body style="background-color:white" style="color:white">
<a href='https://postimg.cc/HcqsMVZP' target='_blank'><img src='https://i.postimg.cc/HcqsMVZP/NY-K13-large-small.jpg' border='0' alt='NY-K13-large-small'/ width="300" height="500"></a>
<h1>Countdown-Timer</h1>
<div class="Countdown-Timer">
<div class="days">
<p class="big-text" id="hours">0</p>
<span>days</span>
</div>
<div class="hours">
<p class="big-text" id="hours">0</p>
<span>hours</span>
</div>
<div class="minutes">
<p class="big-text" id="minutes">0</p>
<span>minutes</span>
</div>
<div class="seconds">
<p class="big-text" id="days">0</p>
<span>seconds</span>
</div>
</div>
</form>
</body>
</html>