While循环语法错误

提姆

该课程要求我形成一个while循环,而我不断收到错误或无限循环。我究竟做错了什么?

var understand = true;

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

您使用的是赋值运算符(=),而不是等于测试(==)。

使用: while(understand == true)

或简化: while(understand)

来自评论的更新:

===表示值和数据类型必须相等,同时==会在比较之前尝试将它们转换为相同类型。

例如:

"3" == 3 // True (implicitly)
"3" === 3 // False because a string is not a number.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章