Answer to Question #210311 in HTML/JavaScript Web Application for jayanth

Question #210311

Given two boolean values

  1. isGrassTrimmerFound and isWaterHosePipeFound as inputs, create three JS promises using async/await and try/catch blocks. For cutting the grass,
  • resolve with "Grass Trimmed" text, if the isGrassTrimmerFound is true
  • reject with "Grass Trimmer Not Found" text, if the isGrassTrimmerFound is false
  1. For cleaning the garden,
  • resolve with "Garden Cleaned" text
  1. For watering the plants,
  • resolve with "Watered Plants" text, if the isWaterHosePipeFound is true
  • reject with "Water Hose Pipe Not Found" text, if the isWaterHosePipeFound is false

Input

  • The first line of input contains a boolean isGrassTrimmerFound
  • The second line of input contains a boolean isWaterHosePipeFound

Sample Input 1

true

true

Sample Output 1

Grass Trimmed

Garden Cleaned

Watered Plants

Sample Input 2

true

false

Sample Output 2

Grass Trimmed

Garden Cleaned

Water Hose Pipe Not Found




1
Expert's answer
2021-06-25T16:06:25-0400
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Series of Operations</title>
<script language="javascript" type="text/javascript">
    window.onload = function () {
        btnSubmit.addEventListener("click", displayResult);
        function displayResult() {
            if (txtNumbers.value != "") {
                var numbers = txtNumbers.value.split(",");
                var outputResult = "Multiply each value with 9:\n";
                for (var i = 0; i < numbers.length; ++i) {
                    numbers[i] *= 9;
                }
                outputResult += "[" + numbers.join(",") + "]\n";
                outputResult += "Subtract 20 from each value:\n";
                for (var i = 0; i < numbers.length; ++i) {
                    numbers[i] -= 20;
                }
                outputResult += "[" + numbers.join(",") + "]\n";
                outputResult += "Multiply each value with 7:\n";
                for (var i = 0; i < numbers.length; ++i) {
                    numbers[i] *= 7;
                }
                outputResult += "[" + numbers.join(",") + "]\n";


                txtResult.value = outputResult;
            } else {
                alert("Enter numbers!!!")
            }
        };
    }
    </script> 
</head>
<body>
	  <form>
		    Enter the values of array using comma. Example 12, 2, 2, 4, 1: <br />
            <input id="txtNumbers" type="text" value="">
            <input id="btnSubmit" type="button" value="Submit">
		  </p>
			<textarea id = "txtResult" rows = "10" cols = "50">
			</textarea>
        </form>
</body>
</html>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS