I have done this before in other environments and it worked so I suspect it's an environment problem. See link: https://replit.com/@MargaretGuzman/Demo#script.js
I expected the script to update the contents of the element to "hi".
const box = document.getElementById("demo");
box.innerText = "hi";
html, body {
height: 100%;
width: 100%;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>replit</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="demo">before</div>
</body>
</html>