Jump to content

Recommended Posts

Posted (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 by webmanz
  • 2 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...