How come count is always 0 even though there are words in the file that match the word to be found?
getWordCount (wordToFind, files) {
var count = 0;
for (let i in files) {
FS.readFile(files[i], 'utf8', function (err, data) {
data.split(/\s+/).forEach(function (word) {
if (word == wordToFind) {
count = count + 1;
}
});
});
}
console.log('Word Count for word: ' + wordToFind + ' is: ' + count);