Hello I havent used vanilla js in a couple months and went to go make a simple count function like the basic react one, I know the logic works because it works when I run it with live preview from vs code, but when I run the server and visit the local host port it does not work, what am i doing wrong?
i have server js which looks like
const express = require("express");
const app = express();
app.get("/", function(req, res){
res.sendFile(__dirname + "/index.html");
})
app.listen(3000, function(){
console.log("server started on port 3000");
});
the file where the logic is
var count = 0;
const addBtn = document.getElementById("add");
addBtn.addEventListener("click", () => handleClick());
function handleClick() {
count++;
console.log(count);
document.getElementById("number").innerHTML = count;
}
and the html
<body>
<h1>
"hello".
</h1>
<h1 id="number">0</h1>
<button id="add">Click me</button>
<script src='app.js'></script>
</body>