我正在尝试使用++
运算符增加一个变量,但我不断得到NaN
结果,我不知道为什么。这是我的代码:
var wordCounts = { };
var x = 0
var compare = "groove is in the heart";
var words = compare.split(/\b/);
for(var i = 1; i < words.length; i++){
if(words[i].length > 2){
wordCounts["_" + words[i]]++;
}
}
alert(wordCounts.toSource());