【求助】javascript代码问题
1) 这段代码: var x="",i=0;
for (i=0;i<10;i++)
{
if (i==3)
{
break;
}
x=x + "The number is " + i + "<br>";
}
document.getElementById("demo").innerHTML=x;
输出:
The number is 0
The number is 1
The number is 2
2)上面的代码换成:
var x="",i=0;
for (i=0;i<10;i++)
{
if (i==3)
{
break;
}
x="The number is " + i + "<br>";
}
document.getElementById("demo").innerHTML=x;
输出:
The number is 2。
请问为什么呢??会少输出2行结果~~~