JavaScript Tutorial/Math/max
Версия от 18:52, 25 мая 2010; (обсуждение)
Find the maximum number by using the Math.max
<html>
<head>
<title>Finding the maximum number</title>
<script type="text/javascript" language="javascript">
<!-- //
function f(){
var MaxNum = Math.max(1,2,3);
document.write(MaxNum);
}
// -->
</script>
</head>
<body onload="f()">
</body>
</html>
Math.max()
Syntax
math.max(num1, num2)
Use Math.max to get the maximum value among three
<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
<!--
inp1 = 1;
inp2 = 2;
inp3 = 3;
document.write("The largest number entered was " + Math.max(inp1, inp2, inp3));
// -->
</script>
</head>
<body>
</body>
</html>