我是 JavaScript 的新手,正在学习教科书。我写了下面的代码,并且警报模式窗口正确显示,但document.writeln(triangle(8,5))
什么也没做。为什么?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Area of Triangle</title>
</head>
<body>
<h1>Area of Triangle</h1>
<pre>
<script type="text/javascript" charset="utf-8">
<!--
var triangle;
triangle = function(base, height) {
return base * height / 2;
};
alert(triangle(8, 5));
documnt.writeln(triangle(8, 5));
-->
</script>
</pre>
</body>
</html>
谢谢你的好意。