Promise Practice Set 8/ 9

 Make a promise and use .then to log in console


Given a string errorMessage as an input, create a JS promise, reject with the given errorMessage , consume the promise using catch() syntax and log the response.

#This is how we can make a new Promise and return that using .then .catch method


Validate User PIN 

Given a correct pin correctPin in the prefilled code and userInput as an input, create a JS promise, resolve with Success text, if the userInput matches with the correctPin reject with Please enter valid pin text, if the userInput mismatches with the correctPin Log the responses using promise .then(), .catch() syntax.

Tree Planting 

Given a boolean isResourceAvailable as an input, create a JS promise, resolve with Tree Planted text, if the isResourceAvailable is true reject with Resource not available text, if the isResourceAvailable is false Use async/await and try/catch blocks.

Search User 

Given a boolean isResourceAvailable as an input, create a JS promise, resolve with Tree Planted text, if the isResourceAvailable is true reject with Resource not available text, if the isResourceAvailable is false Use async/await and try/catch blocks.


___________

Search Employee in a Company

Given an array of objects companies in the prefilled code and companyId , employeeId as inputs, create a JS promise, resolve with Employee Found text, if the companyId matches with the companyCode and the corresponding employees list includes the employeeId in the given companies . reject with Company Not Found text, if the companyId does not match any companyCode in the companies reject with Employee Not Found text, if the corresponding employees does not include employeeId Use async/await and try/catch blocks


_____________

Campfire

We have a task to light a Campfire Given two boolean values isSticksFound and isLighterFound as inputs, create three JS promises using async/await and try/catch blocks.



__________________


STRING OPERATION FUNCTION OF MODERN JS 

____________________

Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

Contact Form