Here is the code that I am using.
JS
const clockContainer = document.querySelector('.js-clock'),
clockTitle = clockContainer.querySelector('h1');
function getTime() {
const date = new Date();
const minutes = date.getMinutes();
const hours = date.getHours();
const seconds = date.getSeconds();
clockTitle.innerText = `${hours}:${minutes}:${seconds}`;
}
function init() {
getTime();
}
init();
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>clock</title>
</head>
<body>
<div class="js-clock">
<h1>00:00</h1>
</div>
<script src="clock.js"></script>
</body>
</html>
Its not working in CodeSandbox but able in vscode why?
I don't know why.... I have tried almost everything, but this code doesn't working in codesandbox