-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeanCounting.js
More file actions
23 lines (16 loc) · 812 Bytes
/
BeanCounting.js
File metadata and controls
23 lines (16 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* Write a function countBs that takes a string as its only argument and returns a number that indicates how many uppercase "B" characters there are in the string.
Next, write a function called countChar that behaves like countBs, except it takes a second argument that indicates the character that is to be counted(rather than counting only uppercase "B" characters). Rewrite countBs to make use of this new function. */
function countBs(str) {
for (let Count of str) {
console.log(count);
}
}
countBs("bbbbBBBjkjdfbb");
// Rewrite the function countBs
function countChar( char, count) {
for (var i = 0; i < count.length; i++) {
return count.length;
}
return 0;
}
console.log(countChar('BBBBB', 'hello world')); // Only the second argument is return