Your fix is not enough.
frasi
is nullable so you need frasi &&
to make sure it's not null.
var frasi = text.match(/[\.\:\?\!\;]/g);
var nF = frasi && frasi.length || 0;
or, make frasi
non-nullable.
var frasi = text.match(/[\.\:\?\!\;]/g) || [];
var nF = frasi.length;
And evt.button
can be integrated with other conditions
if (evt.button === 2 && evt.target.tagName && evt.target.tagName.toLowerCase() === "textarea") {
gulpease(evt.target.textContent);
}