webmanz Posted June 11, 2018 Report Share Posted June 11, 2018 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> <html> <head> <meta charset="UTF-8"> <title> Ch7 Javscript Loops</title> <script> 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!"; //button.style.fontSize="34px"; } </script> </head> <body> <h1>Looping can make your code spin!</h1> <input type="button" id="looper" value="Do it again!"> <p id="target"></p> <script> document.getElementById("looper").onclick=function(){ doItAgain(); this.style.color="red"; } </script> </body> </html> Quote Link to comment Share on other sites More sharing options...
administrator Posted June 13, 2018 Report Share Posted June 13, 2018 On 6/11/2018 at 7:41 PM, webmanz said: for (var i=10; i>=0; i--) It is in the above code snippet. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.