Skip to content

Commit ea7e00c

Browse files
committed
In 2-practice-tdd, created a function to handle count characters
1 parent 8558783 commit ea7e00c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Sprint-3/2-practice-tdd/count.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
function countChar(stringOfCharacters, findCharacter) {
2-
return 5
2+
const arrayOfCharacters = stringOfCharacters.split("");
3+
let count = 0;
4+
for (let index = 0; index < arrayOfCharacters.length; index++) {
5+
if (arrayOfCharacters[index] === findCharacter) {
6+
count += 1;
7+
}
8+
}
9+
console.log(arrayOfCharacters);
10+
console.log(count);
11+
return count;
312
}
413

514
module.exports = countChar;

0 commit comments

Comments
 (0)