This is my code:
String.prototype.count = function(character) {
var seq = new RegExp('/'+character+'/g');
var matches = this.toString().match(seq);
return matches
};
'hello world'.count('o');
This is what it should do:
- Return array of
o
s
This is what it's doing:
- Return null