title: Make a simple javascript timer
body: <p>Hey i am trying to make a small 20 seconds timer for an application on the discord API(javascript)...I got many answers online but none seemed to prove succesful. Can anyone help me? This is the code I originally wrote</p>
  
  <pre><code>            setTimeout(function(){ var af = 0; while(af&lt;21){ af = af+1;  if(af == 20){ break; } console.log(af);} }, 1000);
              message.reply("check the console"); // Part of the discord.js library...nothing to do with the timer
  </code></pre>
  
  <p>But the var af did not decrease by 1 every second...it became 20 in less than a second.. i.e the setTimeout() did not get followed..can u help me?</p>