10 hours
- Medium
Free online content available in this course.
course.header.alt.is_video
course.header.alt.is_certifying
Got it!Last updated on 4/2/20
Use asynchronous programming
Evaluated skills
- build and send AJAX requests
- handle AJAX response data
- use async/await
- handle errors
Question 1
Which of the following correctly handles a promise?
- myPromise.try((data) => {console.log(data);}).catch((error) => {console.log(error);});
- myPromise.then((data) => {console.log(data);}).catch((error) => {console.log(error);});
- myPromise.then((data) => {console.log(data);}).error((error) => {console.log(error);});
- myPromise.resolve((data) => {console.log(data);}).reject((error) => {console.log(error);});
Question 2
Which of the following describes the three states of a promise?
- Promise is started
- Promise is pending
- Promise is resolved
- Promise is implemented
- Promise is resolved
- Promise is complete
- Promise is pending
- Promise is resolved
- Promise is rejected
- Promise is resolved
- Promise is rejected
- Promise is complete
Question 3
Which of the following correctly creates a function which returns a promise?
- function makeMeAPromise() {return new Promise((resolve, reject) => {// Do some stuff hereif (success) {resolve(successData);}else {reject(errorData);}});}
- function makeMeAPromise() {return new Promise(resolve, reject) => {// Do some stuff hereif (success) {resolve(successData);}else {reject(errorData);}};}
- function makeMeAPromise() {return new Promise((resolve, reject) => {// Do some stuff heresuccess.then(data).catch(error);});}
- function makeMeAPromise() {return new Promise((resolve, reject) => {// Do some stuff hereif (success) {return successData}else {return error;}});}
Ever considered an OpenClassrooms diploma?
- Up to 100% of your training program funded
- Flexible start date
- Career-focused projects
- Individual mentoring
Find the training program and funding option that suits you best