These are instruction for further exercise on promises.
Read the steps in order, as you're not supposed to fork this repository but rather create your own.
Note: You might require to google informations if you don't remember how to do everything! Even better, do this together as a part of a group call.
- Create a new folder in your computer called
week6_homework
. - Initialise a new git repository inside the folder.
- Create a new repository called
week6-homework
on Github. Keep it empty, don't add Readme or License. - Add the new Github repository address as a remote called
origin
to your local git repository. - Create a
README.md
file and write a small description. - Commit and push to Github.
- Post the link in the class channel.
- In your homework repository, create a new file called
01_promise.js
. - Write a function that returns a promise. This promise should resolve, returning the string
"success"
. - Commit and push.
- In your homework repository, create a new file called
02_promiseSelector.js
. - Write a function that returns a promise. This promise should resolve, returning the string
"success"
, if the function is passedtrue
as argument. Otherwise, it should reject with the string"failure"
. - Commit and push.
- In your homework repository, create a new file called
03_promiseDelay.js
. - Write a function that returns a promise. This promise should resolve, returning the string
"success"
, after 1 second.- use
setTimeout()
to implement the delay.
- use
- Commit and push.
- In your homework repository, create a new file called
04_promisifiedTimeout.js
. - Write a function that returns a promise. This promise should resolve, returning the string
"success"
, after the amount of milliseconds passed as an argument to the function.- use
setTimeout()
to implement the delay. - note: you effectively 'promisified'
setTimeout()
, transforming a function that use the callback pattern to one that use promises!
- use
- Commit and push.