title: Async for loop nodeJS
body: <p>I have a simple for loop containing an async function, my problem is that the loop goes through all the values, then only executes the async function inside. </p>
  
  <pre><code>for(key in splitedDataArray){
      calculatePower(splitedDataArray[key]);
      var octopusMAC = getOctopusIDFromRaw(splitedDataArray[key]);
      var channelID = getChannelIDFromRaw(splitedDataArray[key]);
      console.log("outside")
      getChannelCTSize(octopusMAC, channelID, function (result) {
          console.log("inside")
          var timestamp = convertDateTimeToInt(transmission.date);
          var adcTicks = getAdcTicksFromRaw(splitedDataArray[key]);
          var power = convertAdcTicksToAmps(parseInt(adcTicks, 16), result);
          console.log("channelID: " + channelID + " ADC ticks HEX: " + adcTicks + " timestamp: " + timestamp + " power for " + result + "A CT Size: " + power);
      });
  }
  </code></pre>
  
  <p>So it prints outside for every element in the array then it only prints inside after all of the outised's, I want to have an outside then and inside and so on. I have looked at <a href="https://www.promisejs.org/" rel="nofollow noreferrer">https://www.promisejs.org/</a> but I am not sure on how to implement this with my code.</p>