Skip to content

Commit 18a4d3e

Browse files
committed
Fixed errors
1 parent be7308e commit 18a4d3e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
function countChar(stringOfCharacters, findCharacter) {
2-
let total = 0;
3-
for (let i=0; i < stringOfCharacters.length; i++){
4-
if (findCharacter == stringOfCharacters[i]){
5-
total++;
2+
let count = 0;
3+
for (let char of stringOfCharacters) {
4+
if (char === findCharacter) {
5+
count++;
66
}
7-
}
8-
return total;
7+
}
8+
return count;
99
}
1010

1111
module.exports = countChar;

0 commit comments

Comments
 (0)