Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
Do-While Loop Not Working | TimeOut might be the problem HTML and JS

I am trying to create a growing/shrinking effect with WebGL.
I approached this problem by using setTimeout().
I incorporated a do-while loop so that this process can repeat

However, the growing/shrinking only occurs once.

My Code:

document.getElementById("groNShrink").onclick = function()
  {
  var millisecondsToWait = 500;
  var max                = 3; // Max times
  do
    {
    balloonEffect++;
    for (var i = 0; i < max; i++)
      {
      setTimeout(function () 
        {
        changeRadius /= 1.15;
        }
        , millisecondsToWait * i);
      }
    setTimeout(function ()
      {
      for (var x = max; x !== 0; x--) 
        {
        setTimeout(function () 
          {
          changeRadius *= 1.15;
          }
          , millisecondsToWait * x);
        }
      }
      , millisecondsToWait * max);
    } 
  while (balloonEffect % 2 == 0);
  };

This is just my for my do-while loop.
I don't see where I went wrong maybe another pair of eyes will help.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!