2.js

// problem: why does it log out out 1000?
// fix it to log 100, 200, 300, 400, 500 etc
// loops 10 times from 0 - 1000 in increments of 100

/*
REASON : callback is passed to another function as a parameter, and the callback function is called (executed) inside otherFunction.	
*/

for (var i = 0; i < 1000; i += 100) {
  waitFor(i, function then() {
    console.log(i)
  })
}

// this will run a callback function after waiting milliseconds
function waitFor(milliseconds, callback)
{
  setTimeout(callback, milliseconds)
}

//***************************************************************SOLUTION***********************************************************************

for (var i = 100; i <= 1000; i += 100) {    //initialize i=100;
  waitFor(i,console.log(i))   //Removed function then()
  }
 
// this will run a callback function after waiting milliseconds
function waitFor(time,callback)
{
   setTimeout(callback, time) 
}