Gardening
We have a task to do Gardening.
Given two boolean values
isGrassTrimmerFound
and
isWaterHosePipeFound
Sample Input 1
Sample Output 1Sample Input 2Sample Output 2
<!DOCTYPE html>
<html>
<body>
<h2>Sample Output 1</h2>
<p id="demo1"></p>
<br/>
<p id="demo2"></p>
<br/>
<p id="demo3"></p>
<script>
function display1(some) {
document.getElementById("demo1").innerHTML = some;
}
function display2(some) {
document.getElementById("demo2").innerHTML = some;
}
function display3(some) {
document.getElementById("demo3").innerHTML = some;
}
//Assuming that isGrassTrimmerFound and isWaterHosePipeFound are true
let isGrassTrimmerFound = true;
let isWaterHosePipeFound = true;
//Promise 1
async function promise1() {if(isGrassTrimmerFound == true){return "Grass Trimmed";}
else{
return "Grass Trimmer Not Found";
}
}
promise1().then(
function(value) {display1(value);},
function(error) {display1(error);}
);
//Promise 2
async function promise2() {if(isWaterHosePipeFound == true){return "Garden Cleaned";}
else{
return "Garden is not cleaned";
}
}
promise2().then(
function(value) {display2(value);},
function(error) {display2(error);}
);
//Promise 3
async function promise3() {if(isWaterHosePipeFound == true){return "Watered Plants";}
else{
return "Water Hose Pipe Not Found";
}
}
promise3().then(
function(value) {display3(value);},
function(error) {display3(error);}
);
</script>
</body>
</html>
Comments
Leave a comment