MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript / countChar

Function countChar

code/solutions/03_3_bean_counting.js:1–9  ·  view source on GitHub ↗
(string, ch)

Source from the content-addressed store, hash-verified

1function countChar(string, ch) {
2 let counted = 0;
3 for (let i = 0; i < string.length; i++) {
4 if (string[i] == ch) {
5 counted += 1;
6 }
7 }
8 return counted;
9}
10
11function countBs(string) {
12 return countChar(string, "B");

Callers 2

countBsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected