Sample Input 1
true
true
Sample Output 1
Grass Trimmed
Garden Cleaned
Watered Plants
Sample Input 2
true
false
Sample Output 2
function grassTrimmer(param){
return new Promise((resolve,reject)=>{
if(param === true){
resolve("Grass Trimmed");
}else{
reject("Grass Trimmer not Found");
}
})
}
function watering(param){
return new Promise((resolve,reject)=>{
if(param === true){
resolve("Watered Plants");
}else{
reject("Water Hose pipe not found");
}
})
}
function gardenCleaning(){
if(isGrassTrimmerFound === true && isWaterHosePipe === true){
return new Promise((resolve,reject)=>{
resolve("Garden Cleaned");
})
}else{
return new Promise((resolve,reject)=>{
reject("Garden not Cleaned")
})
}
}
async function checkCleanliness(isGrassTrimmerFound,isWaterHosePipe){
try {
let trimmerCheck = await grassTrimmer(isGrassTrimmerFound).then((res)=>console.log(res)).catch((res)=>console.log(res));
let waterCheck = await watering(isWaterHosePipe).then((res)=>console.log(res)).catch((res)=>console.log(res));
let gardenCheck = await gardenCleaning().then((res)=>console.log(res)).catch((res)=>console.log(res));
} catch (error) {
console.log(error);
}
}
//inputs
let isGrassTrimmerFound = true;
let isWaterHosePipe = true;
checkCleanliness(isGrassTrimmerFound,isWaterHosePipe);
//Output
/*
Grass Trimmed
Watered Plants
Garden Cleaned
*/
Comments
Leave a comment