A novice attempt to create JavaScript promise pattern.