如何在循环时执行此操作

时间:2014-08-26 03:56:59

标签: javascript

var understand = true;    
while( ){
    console.log("I'm learning while loops!");    
    understand = false;
}

我应该在括号中添加什么来打印“我正在学习循环!”

2 个答案:

答案 0 :(得分:0)

在parens中添加understand会使其打印"I'm learning while loops!"然后停止(因为打印后understand设置为false)。

答案 1 :(得分:0)

您需要在while循环中传递语句:

var understand = true;    
while( understand ){ //while understand == true
    console.log("I'm learning while loops!");    
    understand = false;
}

详细了解while here