Can anyone explain these snippet (just line with the comment above) to me?
function wordRate(word, str) {
let words = str.match(/\w+/g) || [];
// What does these comparison or whatever it is?
return words.filter(w => w == word).length / words.length;
}
Array.filter expects a function as first parameter: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
What is done here instead?