Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String.prototype.amountOfCertainCharacter = function(char) {
- return this.split("").filter(k => k === char).length
- }
- // example
- // code | expected output
- "testing".amountOfCertainCharacter("t") // 2
- "testing".amountOfCertainCharacter("e") // 1
- "testing".amountOfCertainCharacter() // 0
- "testing".amountOfCertainCharacter("q") // 0
Add Comment
Please, Sign In to add comment