In: Computer Science
Write a JavaScript program with a function named fives that reads two numbers from two text fields and then outputs to a div "True" if both of the numbers are greater than 5 or if their sum is greater than 20. Otherwise your function should output "False" to the div. If you wish, you may use the following HTML code to begin your program.
Hey Please find the following javascript solution below:
*****************************************************************************
<!DOCTYPE html>
<html>
<body>
<div>
<div>
<h1>Operations in Javascript</h1>
</div>
Enter First Number : <br>
<input type="text" id="Text1" name="TextBox1">
<br>
Enter Second Number : <br>
<input type="text" id="Text2" name="TextBox2">
<br>
Result : <br>
<input type="text" id="txtresult" name="TextBox3">
<br>
<input type="button" name="clickbtn" value="Display Result"
onclick="fives()">
<script type="text/javascript">
function fives() {
var first_number =
parseInt(document.getElementById("Text1").value);
var second_number =
parseInt(document.getElementById("Text2").value);
var result = first_number + second_number;
if((first_number > 5 &&
second_number > 5) || result > 20)
document.getElementById("txtresult").value = "TRUE";
else
document.getElementById("txtresult").value = "FALSE";
}
</script>
</html>
***************************COMPLETE*******************************
SAMPLE OUTPUT:
Please don't forget to thumbs up if it helped you.
Thanks and happy coding :)
****************************COMPLETE****************************