0

これは、午前 5 時近くになることと関係があると確信しています...そして、明らかな何かが欠けていると思います。

これが私のコードです:

var dayInMonth = 2,
    lastDayNum = 30;

console.log(dayInMonth, (dayInMonth > lastDayNum)); // displays "2 false"

for(dayInMonth; dayInMonth > lastDayNum; dayInMonth++){
    console.log("here!") // not displaying anything
}

forループがconsole.log()ステートメントを実行するのを止めているのは何ですか?

4

6 に答える 6

1

dayInMonth > lastDayNum大きくなることはない

于 2012-09-14T08:57:26.153 に答える
1

dayInMonth > lastDayNumであるべきdayInMonth <= lastDayNumですよね?

于 2012-09-14T08:57:41.397 に答える
1
for(dayInMonth; dayInMonth < lastDayNum; dayInMonth++){
    alert("here!") // not displaying anything
}​

あなたは<したくない>。

于 2012-09-14T08:57:58.217 に答える
1

試す

dayInMonth < lastDayNum

for ループは、2 番目のパラメーターが false になるまでではなく、true である限り実行されます。

于 2012-09-14T08:58:25.750 に答える
1
var dayInMonth = 2,
    lastDayNum = 30;

console.log(dayInMonth, (dayInMonth > lastDayNum)); // displays "2 false"

for(dayInMonth; dayInMonth < lastDayNum; dayInMonth++){
    console.log("here!") // not displaying anything
}

< ではなく > の内側

于 2012-09-14T08:59:07.853 に答える
1

間違った論理テスト (> ではなく <)。

for(; dayInMonth < lastDayNum; dayInMonth++){
    console.log("here!") // not displaying anything
}​
于 2012-09-14T08:59:42.040 に答える