Created
January 19, 2011 23:10
-
-
Save rachelmyers/787083 to your computer and use it in GitHub Desktop.
Week 2 HW Answer for BC's LP:JS class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<HTML> | |
<HEAD> | |
<TITLE>JQuery Homework</TITLE> | |
<SCRIPT type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></SCRIPT> | |
<SCRIPT type="text/javascript"> | |
var x = parseFloat(prompt("Please give me a number.")) | |
var y = parseFloat(prompt("Please give me a number.")) | |
var z = parseFloat(prompt("Please give me a number.")) | |
var sum = x + y + z | |
var product = x * y * z | |
var average = sum / 3 | |
var largest = Math.max(x, y, z) | |
var smallest = Math.min(x, y, z) | |
$(document).ready(function(){ | |
$("#sum").text(sum); | |
$("#product").text(product); | |
$("#average").text(average.toFixed(2)); | |
$("#largest").text(largest); | |
$("#smallest").text(smallest); | |
$("#sum").fadeOut(2000); | |
$("#product").fadeOut(2000); | |
$("#average").fadeOut(2000); | |
$("#largest").fadeOut(2000); | |
$("#smallest").fadeOut(2000); | |
}) | |
// If you want, try replacing .text with other methods, | |
// like .fadeIn(), .fadeOut(), .hide(), .show(), .slideDown() or .toggle(). | |
// Or play with the timing by varying the arguments. | |
</SCRIPT> | |
</HEAD> | |
<BODY> | |
<table> | |
<tr> | |
<th>Sum</th> | |
<th>Product</th> | |
<th>Average</th> | |
<th>Largest</th> | |
<th>Smallest</th> | |
</tr> | |
<tr> | |
<td id="sum"></td> | |
<td id="product"></td> | |
<td id="average"></td> | |
<td id="largest"></td> | |
<td id="smallest"></td> | |
</tr> | |
</table> | |
</BODY> | |
</HTML> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment