Zidan
Zidan

Reputation: 21

i want to print the value of "i" from 0 to 1000

<!DOCTYPE html>
<html>
<body>
/*how ican make String.fromCharCode(i)

i take value from 0 to 1000 so print out letter every time */

JavaScript For Loop

<p id="demo"></p>

<script>
var text = "";
var i;
for (i = 0; i < 1000; i++) {
/*String.fromCharCode(i) "i" print the letter only 1000 
and i want to print from 0 to 1000 */
text = String.fromCharCode(i)+ "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>

</body>
</html>

Upvotes: 2

Views: 917

Answers (1)

Nuno Azevedo
Nuno Azevedo

Reputation: 144

<!DOCTYPE html>
<html>
  <body>
    <h2>JavaScript For Loop</h2>
    <p id="demo"></p>

    <script>
      let text = "";
      for (let i = 0; i < 1000; i++) {
        text += i + "<br>";
      }

      document.getElementById("demo").innerHTML = text;
    </script>

  </body>
</html>

Upvotes: 1

Related Questions