JS综合案例:挑选出随机生成的两个数中的最大数

来自CloudWiki
跳转至: 导航搜索
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>综合案例比较两个数的大小示例</title>
</head>
<body>
<pre>
<script type="text/javascript">
	var	x = Math.random();
	var y = Math.random();
	var max = x>y?x:y;
	document.write("x=");document.write(x);
	document.write("<br />");
	document.write("y=");document.write(y);
	document.write("<br />");
	document.write("最大值是:");document.write(max);
</script>
</pre>
</body>
</html>