Webbserver - Love Blomberg

Show sourcecode

The following files exists in this folder. Click to view.

public_html/gamla-kurser/webbutv2/övningar/js_while/

js_while_a.html
js_while_b.html
js_while_c.html
js_while_d.html
js_while_e.html
js_while_f.html
js_while_g.html
js_while_h.html
js_while_i.html

js_while_d.html

26 lines ASCII Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS While D</title>
</head>
<body>
    <h1>JS While D</h1>

    <button onclick="myFunction()">Klicka mig</button>
    <div id="divruta"></div>
    <script>
        let textruta = document.getElementById("divruta");
        function myFunction() {
            let i = 1;
            let resultat = 0;
            while (i <= 1000) {
              resultat += i;
              console.log(i);
              i++;
            }
            textruta.innerHTML = resultat.toString();
        }
    </script>
</body>
</html>