xxxxxxxxxx
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Variables in HTML</title>
</head>
<body>
<h1 id="heading">Hello, codedamn!</h1>
<button id="updateBtn">Update Text</button>
<script>
let name = "World";
const updateText = () => {
document.getElementById("heading").innerHTML = `Hello, ${name}!`;
}
document.getElementById("updateBtn").addEventListener("click", updateText);
</script>
</body>
</html>
xxxxxxxxxx
<h3>value of javascript variable are <span id="demo"></span></h3>
<script>
var a=5+10
document.getElementById("demo").innerHTML=a;
</script>