function containsPunctuation(word)
{
var punctuation = [";", "!", ".", "?", ",", "-"];
for(var i = 0; i < punctuation.length; i++)
{
if(word.indexOf(punctuation[i]) !== -1)
{
return true;
}
}
return false;
}
function isStopWord(word, stopWords)
{
for (var i = 0; i < stopWords.length; i += 1)
{
var stopWord = stopWords[i];
if ((containsPunctuation(word)) && (word.indexOf(stopWord) === 0) && (word.length === stopWord.length + 1))
{
return true;
}
else if (word === stopWord)
{
return true;
}
}
return false;
}
在blockquote中,containsPunctuation(word) && (word.indexOf(stopWord) === 0
怎麼樣?有人可以解釋爲什麼他們都等於零?我也不確定爲什麼使用(word.length === stopWord.length + 1)
。有人可以向我解釋一個函數可以等於0嗎?
什麼是輸入值? – Sparrow
這是給出的(「森林甘瓜,亞軍」,[「the」]) –