I've tried several things to make it work. It worked before when I hosted it all on the same file, but now it won't work when I separated it on my script.js.
this is part of my code
var buttonStart = document.getElementById("forward");
var buttonStop = document.getElementById("stop");
buttonStart.addEventListener("click", speedup);
function speedup() {
clearInterval(Interval);
speed = speed + 1;
Interval = setInterval(valuecalc, 1000 / speed);
document.getElementById("speed").innerHTML = speed;
};
buttonStop.addEventListener("click", stopspeed);
function stopspeed() {
clearInterval(Interval);
speed = 0;
document.getElementById("speed").innerHTML = speed;
};
var starts = start();
window.onload = starts;
Here's the live demo it's a sort of clicker game I'm working on: https://jobclicker.netlify.app/
This is my error: script.js:35
Uncaught TypeError: Cannot read properties of null (reading 'addEventListener') at script.js:35:17