We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent be7308e commit 18a4d3eCopy full SHA for 18a4d3e
Sprint-3/2-practice-tdd/count.js
@@ -1,11 +1,11 @@
1
function countChar(stringOfCharacters, findCharacter) {
2
-let total = 0;
3
- for (let i=0; i < stringOfCharacters.length; i++){
4
- if (findCharacter == stringOfCharacters[i]){
5
- total++;
+ let count = 0;
+ for (let char of stringOfCharacters) {
+ if (char === findCharacter) {
+ count++;
6
}
7
- }
8
- return total;
+ }
+ return count;
9
10
11
module.exports = countChar;
0 commit comments