我存储了两个生成模拟两个随机骰子的变量。我正在尝试将它们添加到另一段中,如下所示;但是,添加它们的行会生成“NaN”。有什么建议么?
<!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Rolling Two Dice</title>
</head>
<body>
<p>Your first die rolled a <script>var roll1 = document.write(1 +
Math.floor(6 * Math.random()))</script>.</p>
<p>Your second die rolled a <script>var roll2 = document.write(1 +
Math.floor(6 * Math.random()))</script>.</p>
<p>The total of your rolls is <script>document.write(roll1 +roll2)</script>.</p>
</body>
</html>