为什么我的变量之间的差距不会出现,有点困惑。为了您的信息,我使用sublime text 3,并在Internet Explorer浏览器上启动所有内容。
var num1 = 10;
var num2 = 45;
var sum = num1 + num2;
var product = num1 * num2;
var divide = num1 / num2;
var mod = num1 % num2;
document.write(sum + '' + product + '' + divide + '' + mod);
<div class="header">
<h1>Learning Javascript</h1>
<p>With Andrew Milicevic</p>
</div>
<div class="container">
</div>
答案 0 :(得分:1)
您需要在引号之间添加空格字符:''
与' '
。
试试这个:
var num1 = 10;
var num2 = 45;
var sum = num1 + num2;
var product = num1 * num2;
var divide = num1 / num2;
var mod = num1 % num2;
document.write(sum + ' ' + product + ' ' + divide + ' ' + mod);
&#13;
<div class="header">
<h1>Learning Javascript</h1>
<p>With Andrew Milicevic</p>
</div>
<div class="container">
</div>
&#13;