Permalink
Browse files

Correcting word count loop using null regex match result

  • Loading branch information...
1 parent 0045c74 commit 35b2b4b62e1ebbe5c034e6dbe2425a9a80c38e3a @viveleroi viveleroi committed Feb 21, 2014
Showing with 1 addition and 0 deletions.
  1. +1 −0 src/intro.js
View
@@ -343,6 +343,7 @@ function wordCount(data) {
var pattern = /[a-zA-Z0-9_\u0392-\u03c9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g;
var m = data.match(pattern);
var count = 0;
+ if( m === null ) return count;
for (var i = 0; i < m.length; i++) {
if (m[i].charCodeAt(0) >= 0x4E00) {
count += m[i].length;

0 comments on commit 35b2b4b

Please sign in to comment.