In Javascript, I am trying to create a counting loop that adds one to a number. I am new to counting loops in the context of Javascript, but i tried my best and found something from the Internet.
This is my code:
var number = document.getElementById("mainText")
for (let i = number; i < 101; i++) {
number += 1;
}
I am also going to add the HTML for context.
<!DOCTYPE html>
<html>
<head>
<title>Loading....</title>
<link rel="stylesheet" href="./starting.css">
</head>
<script src="https://kit.fontawesome.com/1f2023aaf1.js" crossorigin="anonymous"></script>
<body>
<i id="fa" class="fa fa-spinner fa-10x"></i>"></i><br>
<p id="mainText">0</p>
<p class="idk">%</p>
</body>
</html>
The problem, however, is that when I run it, it still remains at 0(%). Whatever am I doing wrong. Hope this code helps.
Brussels is the capital of Belgium by the way.