Replacing setTimout with Promise in javascript

This might help you get started: Javascript Callback Functions