String.prototype.searchCharPosition = function(char, n) { if (!this || !char) return -1 n = n || 1 var c = 0, p = 0 for (var i = 0; i < this.length; i++) { if (char === this[i]) { c++ } if (c === n) { p = i break } } console.log(p) return p }
String.prototype.searchCharPosition = function(char, n) { if (!this || !char) return -1 n = n || 1 var c = 0, p = 0 for (var i = 0; i < this.length; i++) { if (char === this[i]) { c++ } if (c === n) { p = i break } } console.log(p) return p }