For loop pauses, but prints out the Array all at once












0















I'm having trouble Grok'ing a simple JavaScript for loop.



Here is an example:






var arr = ["Banana", "Orange", "Apple", "Mango"];
for (i = 1; i <= 5; ++i) {
setDelay(i);
}

function setDelay(i) {
setTimeout(function(){
for(const value of arr) {
document.write(value);
document.write("<br />");
}
}, i * 1000);
}





What I'm trying to do is pause after it prints the first value, but instead it runs the entire For loop then pauses. I think I'm trying to do something with for loops that just won't work, but I would like to know why.



Any help would be appreciated.



Plunkr here: https://plnkr.co/edit/tnmFrIRTDJI8T294Qh4z?p=preview



The example Javascript, setTimeout loops? didn't help me figure it out. I still got the concept wrong as George Pantazes points out.










share|improve this question

























  • Possible duplicate of Javascript, setTimeout loops?

    – Tyler Roper
    Nov 13 '18 at 19:05






  • 2





    By running your code, you can see that you are printing the entire array within the setTimeout. Instead of looping through the entire arr in the setTimeout for loop, if you access your array like arr[i] and only print one item instead of all of them, your code would work as you intend.

    – George Pantazes
    Nov 13 '18 at 19:06


















0















I'm having trouble Grok'ing a simple JavaScript for loop.



Here is an example:






var arr = ["Banana", "Orange", "Apple", "Mango"];
for (i = 1; i <= 5; ++i) {
setDelay(i);
}

function setDelay(i) {
setTimeout(function(){
for(const value of arr) {
document.write(value);
document.write("<br />");
}
}, i * 1000);
}





What I'm trying to do is pause after it prints the first value, but instead it runs the entire For loop then pauses. I think I'm trying to do something with for loops that just won't work, but I would like to know why.



Any help would be appreciated.



Plunkr here: https://plnkr.co/edit/tnmFrIRTDJI8T294Qh4z?p=preview



The example Javascript, setTimeout loops? didn't help me figure it out. I still got the concept wrong as George Pantazes points out.










share|improve this question

























  • Possible duplicate of Javascript, setTimeout loops?

    – Tyler Roper
    Nov 13 '18 at 19:05






  • 2





    By running your code, you can see that you are printing the entire array within the setTimeout. Instead of looping through the entire arr in the setTimeout for loop, if you access your array like arr[i] and only print one item instead of all of them, your code would work as you intend.

    – George Pantazes
    Nov 13 '18 at 19:06
















0












0








0








I'm having trouble Grok'ing a simple JavaScript for loop.



Here is an example:






var arr = ["Banana", "Orange", "Apple", "Mango"];
for (i = 1; i <= 5; ++i) {
setDelay(i);
}

function setDelay(i) {
setTimeout(function(){
for(const value of arr) {
document.write(value);
document.write("<br />");
}
}, i * 1000);
}





What I'm trying to do is pause after it prints the first value, but instead it runs the entire For loop then pauses. I think I'm trying to do something with for loops that just won't work, but I would like to know why.



Any help would be appreciated.



Plunkr here: https://plnkr.co/edit/tnmFrIRTDJI8T294Qh4z?p=preview



The example Javascript, setTimeout loops? didn't help me figure it out. I still got the concept wrong as George Pantazes points out.










share|improve this question
















I'm having trouble Grok'ing a simple JavaScript for loop.



Here is an example:






var arr = ["Banana", "Orange", "Apple", "Mango"];
for (i = 1; i <= 5; ++i) {
setDelay(i);
}

function setDelay(i) {
setTimeout(function(){
for(const value of arr) {
document.write(value);
document.write("<br />");
}
}, i * 1000);
}





What I'm trying to do is pause after it prints the first value, but instead it runs the entire For loop then pauses. I think I'm trying to do something with for loops that just won't work, but I would like to know why.



Any help would be appreciated.



Plunkr here: https://plnkr.co/edit/tnmFrIRTDJI8T294Qh4z?p=preview



The example Javascript, setTimeout loops? didn't help me figure it out. I still got the concept wrong as George Pantazes points out.






var arr = ["Banana", "Orange", "Apple", "Mango"];
for (i = 1; i <= 5; ++i) {
setDelay(i);
}

function setDelay(i) {
setTimeout(function(){
for(const value of arr) {
document.write(value);
document.write("<br />");
}
}, i * 1000);
}





var arr = ["Banana", "Orange", "Apple", "Mango"];
for (i = 1; i <= 5; ++i) {
setDelay(i);
}

function setDelay(i) {
setTimeout(function(){
for(const value of arr) {
document.write(value);
document.write("<br />");
}
}, i * 1000);
}






javascript






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 19:59







Rostasan

















asked Nov 13 '18 at 19:03









RostasanRostasan

105




105













  • Possible duplicate of Javascript, setTimeout loops?

    – Tyler Roper
    Nov 13 '18 at 19:05






  • 2





    By running your code, you can see that you are printing the entire array within the setTimeout. Instead of looping through the entire arr in the setTimeout for loop, if you access your array like arr[i] and only print one item instead of all of them, your code would work as you intend.

    – George Pantazes
    Nov 13 '18 at 19:06





















  • Possible duplicate of Javascript, setTimeout loops?

    – Tyler Roper
    Nov 13 '18 at 19:05






  • 2





    By running your code, you can see that you are printing the entire array within the setTimeout. Instead of looping through the entire arr in the setTimeout for loop, if you access your array like arr[i] and only print one item instead of all of them, your code would work as you intend.

    – George Pantazes
    Nov 13 '18 at 19:06



















Possible duplicate of Javascript, setTimeout loops?

– Tyler Roper
Nov 13 '18 at 19:05





Possible duplicate of Javascript, setTimeout loops?

– Tyler Roper
Nov 13 '18 at 19:05




2




2





By running your code, you can see that you are printing the entire array within the setTimeout. Instead of looping through the entire arr in the setTimeout for loop, if you access your array like arr[i] and only print one item instead of all of them, your code would work as you intend.

– George Pantazes
Nov 13 '18 at 19:06







By running your code, you can see that you are printing the entire array within the setTimeout. Instead of looping through the entire arr in the setTimeout for loop, if you access your array like arr[i] and only print one item instead of all of them, your code would work as you intend.

– George Pantazes
Nov 13 '18 at 19:06














3 Answers
3






active

oldest

votes


















1














Inside setTimeout - instead of printing entire array just print current element.






var arr = ["Banana", "Orange", "Apple", "Mango"];
for (let i = 1; i < 5; ++i) {
setDelay(i);
}

function setDelay(i) {
setTimeout(function(){
console.log(arr[i-1])
}, i * 1000);
}








share|improve this answer
























  • Why are you using 1-i? Is it better to start with i = 1? I do understand that the array index starts at 0. Oh wait, so the array is four long, so you changed the i to equal 1 match the offset? Would it be better if I did i < arr.length? -Thanks

    – Rostasan
    Nov 13 '18 at 20:04













  • Yes, you are correct because you have 4 array elements and array index starts from 0

    – Nitish Narang
    Nov 13 '18 at 20:07











  • Its better to do i< arr.length. Also, its always preferable to start i with 0 rather than 1

    – Nitish Narang
    Nov 14 '18 at 6:45



















1














There were multiple issues within your code:




  1. Be sure to mind that Javascript arrays are 0-based. You were starting at 1.

  2. Similarly, be sure to mind the ending bound of the index (in your for loop). It was going too far even for a 1-base (it was going to 5 out of 4 available items)

  3. Within the setTimeout, you were printing the entire array by using for(const value of arr). You were probably trying to pass in i as an index to index only one element.


With those comments in mind, here is the working code with those parts changed:






var arr = ["Banana", "Orange", "Apple", "Mango"];
for (i = 0; i < arr.length; ++i) {
setDelay(i);
}

function setDelay(i) {
setTimeout(function(){
document.write(arr[i]);
document.write("<br />");
}, i * 1000);
}








share|improve this answer
























  • Refer to @Nitish-Narang's answer for better Javascript code style, although I think my advice about the indices is worth taking as well.

    – George Pantazes
    Nov 13 '18 at 19:15











  • wow thanks. I tried to do that by setting i = to the array (out of desperation), but this makes a lot more sense. I have access to the array and i. So that would let me use arr[i].

    – Rostasan
    Nov 13 '18 at 20:01



















0














An alternative approach to creating a delay by using setTimeout in a loop is the setInterval function. setInterval will execute the function argument each time a specified duration of of milliseconds passes:






var arr = ["Banana", "Orange", "Apple", "Mango"];
var i = 0;
var intervalId = setInterval(logNext, 1000);

function logNext() {
if (i < arr.length) {
console.log(arr[i++]);
} else {
console.log('End of array reached!');
clearInterval(intervalId);
}
}








share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53287874%2ffor-loop-pauses-but-prints-out-the-array-all-at-once%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Inside setTimeout - instead of printing entire array just print current element.






    var arr = ["Banana", "Orange", "Apple", "Mango"];
    for (let i = 1; i < 5; ++i) {
    setDelay(i);
    }

    function setDelay(i) {
    setTimeout(function(){
    console.log(arr[i-1])
    }, i * 1000);
    }








    share|improve this answer
























    • Why are you using 1-i? Is it better to start with i = 1? I do understand that the array index starts at 0. Oh wait, so the array is four long, so you changed the i to equal 1 match the offset? Would it be better if I did i < arr.length? -Thanks

      – Rostasan
      Nov 13 '18 at 20:04













    • Yes, you are correct because you have 4 array elements and array index starts from 0

      – Nitish Narang
      Nov 13 '18 at 20:07











    • Its better to do i< arr.length. Also, its always preferable to start i with 0 rather than 1

      – Nitish Narang
      Nov 14 '18 at 6:45
















    1














    Inside setTimeout - instead of printing entire array just print current element.






    var arr = ["Banana", "Orange", "Apple", "Mango"];
    for (let i = 1; i < 5; ++i) {
    setDelay(i);
    }

    function setDelay(i) {
    setTimeout(function(){
    console.log(arr[i-1])
    }, i * 1000);
    }








    share|improve this answer
























    • Why are you using 1-i? Is it better to start with i = 1? I do understand that the array index starts at 0. Oh wait, so the array is four long, so you changed the i to equal 1 match the offset? Would it be better if I did i < arr.length? -Thanks

      – Rostasan
      Nov 13 '18 at 20:04













    • Yes, you are correct because you have 4 array elements and array index starts from 0

      – Nitish Narang
      Nov 13 '18 at 20:07











    • Its better to do i< arr.length. Also, its always preferable to start i with 0 rather than 1

      – Nitish Narang
      Nov 14 '18 at 6:45














    1












    1








    1







    Inside setTimeout - instead of printing entire array just print current element.






    var arr = ["Banana", "Orange", "Apple", "Mango"];
    for (let i = 1; i < 5; ++i) {
    setDelay(i);
    }

    function setDelay(i) {
    setTimeout(function(){
    console.log(arr[i-1])
    }, i * 1000);
    }








    share|improve this answer













    Inside setTimeout - instead of printing entire array just print current element.






    var arr = ["Banana", "Orange", "Apple", "Mango"];
    for (let i = 1; i < 5; ++i) {
    setDelay(i);
    }

    function setDelay(i) {
    setTimeout(function(){
    console.log(arr[i-1])
    }, i * 1000);
    }








    var arr = ["Banana", "Orange", "Apple", "Mango"];
    for (let i = 1; i < 5; ++i) {
    setDelay(i);
    }

    function setDelay(i) {
    setTimeout(function(){
    console.log(arr[i-1])
    }, i * 1000);
    }





    var arr = ["Banana", "Orange", "Apple", "Mango"];
    for (let i = 1; i < 5; ++i) {
    setDelay(i);
    }

    function setDelay(i) {
    setTimeout(function(){
    console.log(arr[i-1])
    }, i * 1000);
    }






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 13 '18 at 19:09









    Nitish NarangNitish Narang

    2,9401815




    2,9401815













    • Why are you using 1-i? Is it better to start with i = 1? I do understand that the array index starts at 0. Oh wait, so the array is four long, so you changed the i to equal 1 match the offset? Would it be better if I did i < arr.length? -Thanks

      – Rostasan
      Nov 13 '18 at 20:04













    • Yes, you are correct because you have 4 array elements and array index starts from 0

      – Nitish Narang
      Nov 13 '18 at 20:07











    • Its better to do i< arr.length. Also, its always preferable to start i with 0 rather than 1

      – Nitish Narang
      Nov 14 '18 at 6:45



















    • Why are you using 1-i? Is it better to start with i = 1? I do understand that the array index starts at 0. Oh wait, so the array is four long, so you changed the i to equal 1 match the offset? Would it be better if I did i < arr.length? -Thanks

      – Rostasan
      Nov 13 '18 at 20:04













    • Yes, you are correct because you have 4 array elements and array index starts from 0

      – Nitish Narang
      Nov 13 '18 at 20:07











    • Its better to do i< arr.length. Also, its always preferable to start i with 0 rather than 1

      – Nitish Narang
      Nov 14 '18 at 6:45

















    Why are you using 1-i? Is it better to start with i = 1? I do understand that the array index starts at 0. Oh wait, so the array is four long, so you changed the i to equal 1 match the offset? Would it be better if I did i < arr.length? -Thanks

    – Rostasan
    Nov 13 '18 at 20:04







    Why are you using 1-i? Is it better to start with i = 1? I do understand that the array index starts at 0. Oh wait, so the array is four long, so you changed the i to equal 1 match the offset? Would it be better if I did i < arr.length? -Thanks

    – Rostasan
    Nov 13 '18 at 20:04















    Yes, you are correct because you have 4 array elements and array index starts from 0

    – Nitish Narang
    Nov 13 '18 at 20:07





    Yes, you are correct because you have 4 array elements and array index starts from 0

    – Nitish Narang
    Nov 13 '18 at 20:07













    Its better to do i< arr.length. Also, its always preferable to start i with 0 rather than 1

    – Nitish Narang
    Nov 14 '18 at 6:45





    Its better to do i< arr.length. Also, its always preferable to start i with 0 rather than 1

    – Nitish Narang
    Nov 14 '18 at 6:45













    1














    There were multiple issues within your code:




    1. Be sure to mind that Javascript arrays are 0-based. You were starting at 1.

    2. Similarly, be sure to mind the ending bound of the index (in your for loop). It was going too far even for a 1-base (it was going to 5 out of 4 available items)

    3. Within the setTimeout, you were printing the entire array by using for(const value of arr). You were probably trying to pass in i as an index to index only one element.


    With those comments in mind, here is the working code with those parts changed:






    var arr = ["Banana", "Orange", "Apple", "Mango"];
    for (i = 0; i < arr.length; ++i) {
    setDelay(i);
    }

    function setDelay(i) {
    setTimeout(function(){
    document.write(arr[i]);
    document.write("<br />");
    }, i * 1000);
    }








    share|improve this answer
























    • Refer to @Nitish-Narang's answer for better Javascript code style, although I think my advice about the indices is worth taking as well.

      – George Pantazes
      Nov 13 '18 at 19:15











    • wow thanks. I tried to do that by setting i = to the array (out of desperation), but this makes a lot more sense. I have access to the array and i. So that would let me use arr[i].

      – Rostasan
      Nov 13 '18 at 20:01
















    1














    There were multiple issues within your code:




    1. Be sure to mind that Javascript arrays are 0-based. You were starting at 1.

    2. Similarly, be sure to mind the ending bound of the index (in your for loop). It was going too far even for a 1-base (it was going to 5 out of 4 available items)

    3. Within the setTimeout, you were printing the entire array by using for(const value of arr). You were probably trying to pass in i as an index to index only one element.


    With those comments in mind, here is the working code with those parts changed:






    var arr = ["Banana", "Orange", "Apple", "Mango"];
    for (i = 0; i < arr.length; ++i) {
    setDelay(i);
    }

    function setDelay(i) {
    setTimeout(function(){
    document.write(arr[i]);
    document.write("<br />");
    }, i * 1000);
    }








    share|improve this answer
























    • Refer to @Nitish-Narang's answer for better Javascript code style, although I think my advice about the indices is worth taking as well.

      – George Pantazes
      Nov 13 '18 at 19:15











    • wow thanks. I tried to do that by setting i = to the array (out of desperation), but this makes a lot more sense. I have access to the array and i. So that would let me use arr[i].

      – Rostasan
      Nov 13 '18 at 20:01














    1












    1








    1







    There were multiple issues within your code:




    1. Be sure to mind that Javascript arrays are 0-based. You were starting at 1.

    2. Similarly, be sure to mind the ending bound of the index (in your for loop). It was going too far even for a 1-base (it was going to 5 out of 4 available items)

    3. Within the setTimeout, you were printing the entire array by using for(const value of arr). You were probably trying to pass in i as an index to index only one element.


    With those comments in mind, here is the working code with those parts changed:






    var arr = ["Banana", "Orange", "Apple", "Mango"];
    for (i = 0; i < arr.length; ++i) {
    setDelay(i);
    }

    function setDelay(i) {
    setTimeout(function(){
    document.write(arr[i]);
    document.write("<br />");
    }, i * 1000);
    }








    share|improve this answer













    There were multiple issues within your code:




    1. Be sure to mind that Javascript arrays are 0-based. You were starting at 1.

    2. Similarly, be sure to mind the ending bound of the index (in your for loop). It was going too far even for a 1-base (it was going to 5 out of 4 available items)

    3. Within the setTimeout, you were printing the entire array by using for(const value of arr). You were probably trying to pass in i as an index to index only one element.


    With those comments in mind, here is the working code with those parts changed:






    var arr = ["Banana", "Orange", "Apple", "Mango"];
    for (i = 0; i < arr.length; ++i) {
    setDelay(i);
    }

    function setDelay(i) {
    setTimeout(function(){
    document.write(arr[i]);
    document.write("<br />");
    }, i * 1000);
    }








    var arr = ["Banana", "Orange", "Apple", "Mango"];
    for (i = 0; i < arr.length; ++i) {
    setDelay(i);
    }

    function setDelay(i) {
    setTimeout(function(){
    document.write(arr[i]);
    document.write("<br />");
    }, i * 1000);
    }





    var arr = ["Banana", "Orange", "Apple", "Mango"];
    for (i = 0; i < arr.length; ++i) {
    setDelay(i);
    }

    function setDelay(i) {
    setTimeout(function(){
    document.write(arr[i]);
    document.write("<br />");
    }, i * 1000);
    }






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 13 '18 at 19:13









    George PantazesGeorge Pantazes

    472617




    472617













    • Refer to @Nitish-Narang's answer for better Javascript code style, although I think my advice about the indices is worth taking as well.

      – George Pantazes
      Nov 13 '18 at 19:15











    • wow thanks. I tried to do that by setting i = to the array (out of desperation), but this makes a lot more sense. I have access to the array and i. So that would let me use arr[i].

      – Rostasan
      Nov 13 '18 at 20:01



















    • Refer to @Nitish-Narang's answer for better Javascript code style, although I think my advice about the indices is worth taking as well.

      – George Pantazes
      Nov 13 '18 at 19:15











    • wow thanks. I tried to do that by setting i = to the array (out of desperation), but this makes a lot more sense. I have access to the array and i. So that would let me use arr[i].

      – Rostasan
      Nov 13 '18 at 20:01

















    Refer to @Nitish-Narang's answer for better Javascript code style, although I think my advice about the indices is worth taking as well.

    – George Pantazes
    Nov 13 '18 at 19:15





    Refer to @Nitish-Narang's answer for better Javascript code style, although I think my advice about the indices is worth taking as well.

    – George Pantazes
    Nov 13 '18 at 19:15













    wow thanks. I tried to do that by setting i = to the array (out of desperation), but this makes a lot more sense. I have access to the array and i. So that would let me use arr[i].

    – Rostasan
    Nov 13 '18 at 20:01





    wow thanks. I tried to do that by setting i = to the array (out of desperation), but this makes a lot more sense. I have access to the array and i. So that would let me use arr[i].

    – Rostasan
    Nov 13 '18 at 20:01











    0














    An alternative approach to creating a delay by using setTimeout in a loop is the setInterval function. setInterval will execute the function argument each time a specified duration of of milliseconds passes:






    var arr = ["Banana", "Orange", "Apple", "Mango"];
    var i = 0;
    var intervalId = setInterval(logNext, 1000);

    function logNext() {
    if (i < arr.length) {
    console.log(arr[i++]);
    } else {
    console.log('End of array reached!');
    clearInterval(intervalId);
    }
    }








    share|improve this answer




























      0














      An alternative approach to creating a delay by using setTimeout in a loop is the setInterval function. setInterval will execute the function argument each time a specified duration of of milliseconds passes:






      var arr = ["Banana", "Orange", "Apple", "Mango"];
      var i = 0;
      var intervalId = setInterval(logNext, 1000);

      function logNext() {
      if (i < arr.length) {
      console.log(arr[i++]);
      } else {
      console.log('End of array reached!');
      clearInterval(intervalId);
      }
      }








      share|improve this answer


























        0












        0








        0







        An alternative approach to creating a delay by using setTimeout in a loop is the setInterval function. setInterval will execute the function argument each time a specified duration of of milliseconds passes:






        var arr = ["Banana", "Orange", "Apple", "Mango"];
        var i = 0;
        var intervalId = setInterval(logNext, 1000);

        function logNext() {
        if (i < arr.length) {
        console.log(arr[i++]);
        } else {
        console.log('End of array reached!');
        clearInterval(intervalId);
        }
        }








        share|improve this answer













        An alternative approach to creating a delay by using setTimeout in a loop is the setInterval function. setInterval will execute the function argument each time a specified duration of of milliseconds passes:






        var arr = ["Banana", "Orange", "Apple", "Mango"];
        var i = 0;
        var intervalId = setInterval(logNext, 1000);

        function logNext() {
        if (i < arr.length) {
        console.log(arr[i++]);
        } else {
        console.log('End of array reached!');
        clearInterval(intervalId);
        }
        }








        var arr = ["Banana", "Orange", "Apple", "Mango"];
        var i = 0;
        var intervalId = setInterval(logNext, 1000);

        function logNext() {
        if (i < arr.length) {
        console.log(arr[i++]);
        } else {
        console.log('End of array reached!');
        clearInterval(intervalId);
        }
        }





        var arr = ["Banana", "Orange", "Apple", "Mango"];
        var i = 0;
        var intervalId = setInterval(logNext, 1000);

        function logNext() {
        if (i < arr.length) {
        console.log(arr[i++]);
        } else {
        console.log('End of array reached!');
        clearInterval(intervalId);
        }
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 19:09









        Tom O.Tom O.

        2,36311325




        2,36311325






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53287874%2ffor-loop-pauses-but-prints-out-the-array-all-at-once%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Full-time equivalent

            さくらももこ

            13 indicted, 8 arrested in Calif. drug cartel investigation