webmanz Posted June 11, 2018 Report 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>
administrator Posted June 13, 2018 Report 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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now