title: setTimeout return a promise
body: <p>I am creating a function that has 2 parameters:</p>
  
  <ul>
  <li>parameter 1: a callback function, </li>
  <li>parameter 2: time x (ms)</li>
  </ul>
  
  <p>This function will call the callback function after a period of x ms AND returns a promise.</p>
  
  <p>My code follows. It only prints 'Goodbye' after 1s</p>
  
  <pre><code>function doAfter(func, time) {
    var promise = new Promise(function(resolve, reject) {
      setTimeout(function(data) {
        resolve(data);
      }, time);
    });
    return promise;
  }
  
  function sayHello() {
    console.log('Hello');
  }
  
  function sayGoodbye() {
    console.log('Goodbye');
  }
  
  doAfter(sayHello, 1000).then(sayGoodbye);
  </code></pre>
  
  <p>Expected behaviour: wait 1s, then print 'Hello Goodbye'</p>