哪里錯了,為啥沒有顯示?
<!DOCTYPE? HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函數</title>
<script type="text/javascript">
function compare(a,b)//定義函數
{
? ? if (a>b)
? ? {
? ? ? ? return a;
? ? }
? ? else if(a<b)
? ? {
? ? ? ? return b;
? ? }else
? ? {return "兩數相等"}
? ??
}//函數體,判斷兩個整數比較的三種情況
?
//調用函數,實現下面兩組數中,返回較大值。
? document.write(" 5 和 4 的較大值是:"+compare(5,4)+"<br/>");
? document.write(" 6 和 3 的較大值是:"+compare(6,3)+"<br/>" );?
? document.write(" 88 和88 的較大值是:"+compare(88,88) );?
</script>
</head>
<body>
</body>
</html>
2019-04-04
而且document.write(" 6 和 3 的較大值是:"+compare(6,3)+"<br/>" );里面有中文符號,第二個3后面
2019-04-04
{return "兩數相等";}
你的這一行代碼寫少了一個分號