Promise with Return

by Matthew Day

JavaScript

const wait = function(time) {
	return new Promise(function(resolve) {
  	setTimeout(function() {
    	resolve();
    }, time);
  });
}

// this fiddle is to experiement with Promise using a return as well as writing things in es6

//const wait = time => new Promise((resolve) => setTimeout(resolve, time));
wait(3000).then(() => console.log('Hello!')); // 'Hello!'