webmanz Posted April 24, 2018 Report Posted April 24, 2018 (edited) 3.52 minute mark of chapter 7 part 3 Loops Q1: Why does the + target.innerHTML added at the end (see code below) appear in ascending order on the web page rather than descending like it does in the console.log? I do realize that you can achieve descending result by adding + target.innerHTML in the front to match console.log but I'm curious why when added to the end it gives a ascending order rather than descending order? Here's the code from that lesson 3.52 minute mark of chapter 7 video part 3 Loops: function doItAgain(message){ var loopCount=5; while (loopCount > 0) { var target = document.getElementById("target"); target.innerHTML="LoopCount:" + loopCount + "<br> + target.innerHTML; <------------ referring to this line console.log("loopCount is now:" + loopCount); loopCount=loopCount -1; } console.log ("End loop"); var button= document.getElementById("looper"); button.value="Done looping!"; } Edited April 24, 2018 by webmanz
administrator Posted May 7, 2018 Report Posted May 7, 2018 Sorry for the delay. Has to do how console.log works in the browser. Not important to know those details ... just get your code working in the web browser. Stef
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