哪里有問(wèn)題,看暈了
<!DOCTYPE ?HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函數(shù)</title>
<script type="text/javascript">
? ? function max(a,b){
? ? ? ? if (a>b){
? ? ? ? ? ? document.write(a);
? ? ? ? }
? ? ? ? else if(a==b){
? ? ? ? ? ? document.write(a);
? ? ? ? }
? ? ? ? else{
? ? ? ? ? ? document.write(b);
? ? ? ? }
? ? ? ? }
? ? var aa=max(5,4); ?
? ? var bb=max(6,3);
//調(diào)用函數(shù),實(shí)現(xiàn)下面兩組數(shù)中,返回較大值。
? document.write("5 和 4 的較大值是:"+aa+"<br>");
? document.write(" 6 和 3 的較大值是:"+bb);?
</script>
</head>
<body>
</body>
</html>
2015-08-17
把document.write改成return。你不能調(diào)用了函數(shù),不給返回值,那么它走完函數(shù)體還是沒(méi)有結(jié)果的呀。返回值就相當(dāng)于函數(shù)的結(jié)果。
修改后的代碼你看看
2015-08-17
已經(jīng)習(xí)慣了您的及時(shí)指導(dǎo),哈哈