My JavaScript won't run for my landing page clock. I have tried to put the JavaScript in the head and in the body but it still will not make my clock tick. What is wrong with my code? How do I fix this?
const time = document.getElementById('time'),
greeting = document.getElementById('greeting'),
name = document.getElementById('name'),
focus = document.getElementById('focus');
function showTime() {
let today = new Date(),
hour = today.getHours(),
min = today.getMinutes(),
sec = today.getSeconds();
//Set Am or PM
const amPM = hour >= 12 ? 'PM' : 'AM';
//12hr Format
hour = hour % 12 || 12;
//Output Time
time.innerHTML = '${hour}<span>:</span>${min}<span>:</span>${sec}';
setTimeout(showTime, 1000);
}
Run
showTime();
<!DOCTYPE html>
<html lang="en" <head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css2?
family=Quicksand&display=swap" rel="stylesheet" <title>Welcome Page</title>
</head>
<body>
<time id="time">12:34:56 PM</time>
<h1>
<span id="greeting">Good Afternoon</span>
<span id="name" contenteditable="true">Heather</span>
</h1>
<h2>What Is Your Focus For Today?</h2>
<h2 id="focus" contenteditable="true">FIX THIS ISH ! </h2>
<script src="js/main.js"></script>
</body>
</html>
Run? You probably have an error in the dev tools console.>).<html lang="en" <head>missing closing>for opening html tag. No closing>on the lastlinktag beforetitle