Jump to content

For loop code didn't work like in chapter 7, lesson 4


Recommended Posts

Can someone tell me why my code didn't produce the same results as in Chapter 7 lesson 4.

I only managed to get Loop Count: 10 to appear, I'm not able to get Loop Count: 0 to 9.

<!DOCTYPE html>

      <meta charset="UTF-8">
      <title> Ch7 Javscript Loops</title>
        function doItAgain(message){

        for (var i=10; i>=0; i--) {
            var target = document.getElementById("target");
            target.innerHTML = "LoopCount:" + i + "<br>" + target.innerHTML;
            cosole.log("LoopCount is now: " + i);

            console.log ("End for loop");
            var button = document.getElementById("looper");
            button.value="Done looping!";


    <h1>Looping can make your code spin!</h1>
    <input type="button" id="looper" value="Do it again!">
    <p id="target"></p>





Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...