仅供参考:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
function compare(a,b){
if(a==b){
return a+"和"+b+"相等";
}else if(a>b){
return a+"和"+b+"中较大值的值是:"+a
}else{
return a+"和"+b+"中较大值的值是:"+b
}
}
document.write(compare(2,2)+'<br>');
document.write(compare(5,4)+'<br>');
document.write(compare(6,3)+'<br>');
</script>
</body>
</html>
输出结果: