A simple javascript implmentation of promise object. It isn't the best solution but does solve the given problem statement. The probable todo items/improvements would be to refer MDN doc for Promise
Listing a few here:
.all(iterable)
.reject(promiseInstance)
.resolve(promiseInstance)
.finally(callback)