我是 JavaScript 的新手,当我length键入lenght. 但是,没有针对此错误或语法错误的通知。我花了很长时间调试。我想知道这怎么会发生?如果lenghtJavaScript 可以接受?
var totalFruit = function(tree) {
let windowStart = 0;
let dict = {};
maxLength = 0;
for (let windowEnd = 0; windowEnd < tree.length; windowEnd++) {
currentFruit = tree[windowEnd];
if (!(currentFruit in dict)) {
dict[currentFruit] = 0;
}
dict[currentFruit] += 1;
while (Object.keys(dict).lenght > 2) {
leftFruit = tree[windowStart];
dict[leftFruit] -= 1;
if (dict[leftFruit] == 0) {
delete dict[leftFruit]
windowStart += 1;
}
}
maxLength = Math.max(maxLength, windowEnd - windowStart + 1);
}
return maxLength;
};
三国纷争
呼唤远方
相关分类