【发布时间】:2021-03-20 03:59:09
【问题描述】:
我真的需要帮助,因为我完全被困住了。提前谢谢你
运动:
声明一个名为 countdown 的变量并将其赋值为 10。在 while 循环中,每次迭代将 countdown 的值递减一次并打印出来。一旦倒计时达到 0,将“Blastoff”打印到控制台。
到目前为止我做了什么:
var countdown = 10;{
while (countdown > 0 || 0=== "Blastoff!"){
console.log(countdown);
countdown = countdown - 1;
}
console.log("Blastoff!");
}
这是迄今为止我认为应该是正确的结果:
Output
>>>>Code is incorrect
The first line in your while's block should decrement the value of the variable countdown
10
9
8
7
6
5
4
3
2
1
Blastoff!
【问题讨论】:
-
反馈的不是很清楚吗?打印前需要先递减。
-
0=== "Blastoff!"将总是为假 -
或将
var countdown = 10;改为var countdown = 9; -
我已经尝试过了,它也不起作用。你能指定我应该在哪里以及如何放置它吗?
-
@Cid 如果 OP 在
9声明并初始化countdown,那么显示的第一个数字应该是8,所以你的建议并不能解决问题。
标签: javascript while-loop countdown console.log decrement