PromisThefuckAgain

This commit is contained in:
2024-10-24 15:21:04 +02:00
parent 9e8df7c127
commit b907fa988b
3 changed files with 71 additions and 2 deletions

View File

@ -0,0 +1,71 @@
//PROMISE Object
//Do the chores in order: walk the dog, clean up the kitchen and tak out the trash
// function walkdog(callback) {
// setTimeout(() => {
// console.log("WALKING THE DOG");
// callback();
// }, 3000);
// }
// function cleanKitchen(callback) {
// setTimeout(() => {
// console.log("CLEANING THE KITCHEN");
// callback();
// }, 13000);
// }
// function takeTrash(callback) {
// setTimeout(() => {
// console.log("TAKING THE TRASH");
// callback();
// }, 1000);
// }
// walkdog(() => {
// cleanKitchen(() => {
// takeTrash(() => {
// console.log("DONE");
// });
// })
// })
function walkdog() {
setTimeout(() => {
console.log("WALKING THE DOG");
}, 3000);
return new Promise((resolve, reject) => {
resolve("WALKING THE DOG");
});
}
function cleanKitchen() {
setTimeout(() => {
console.log("CLEANING THE KITCHEN");
}, 13000);
return new Promise((resolve, reject) => {
resolve("Cleaning the kitchen");
});
}
function takeTrash() {
setTimeout(() => {
console.log("TAKING THE TRASH");
}, 1000);
return new Promise((resolve, reject) => {
resolve("TAKING THE TRASH");
})
}
walkdog()
.then((result) => {
console.log(result);
return cleanKitchen();
})
.then((result) => {
console.log(result);
return takeTrash();
})
.then((result) => {
console.log(result);
})

View File

@ -1,2 +0,0 @@
//PROMISE Object