Answer to Question #242930 in HTML/JavaScript Web Application for reddy

Question #242930
Given two boolean values 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
For cleaning the garden,

resolve with "Garden Cleaned" text
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
1
Expert's answer
2021-09-27T15:47:15-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