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 f641d30 commit 9b176d2Copy full SHA for 9b176d2
1 file changed
Sprint-3/2-practice-tdd/count.js
@@ -1,15 +1,15 @@
1
function countChar(stringOfCharacters, findCharacter) {
2
- if(stringOfCharacters === "" || findCharacter === ""){
3
- throw new Error("string an char are not given")
+ if (stringOfCharacters === "" || findCharacter === "") {
+ throw new Error("string an char are not given");
4
}
5
6
- const str = stringOfCharacters.split("")
7
let count = 0;
8
- for(const char of str){
9
- if(char === findCharacter){
10
- count++
+ for (const char of stringOfCharacters) {
+ if (char === findCharacter) {
+ count++;
11
12
13
- return count
+ return count;
14
+console.log(countChar("aaaaaae", "a"));
15
module.exports = countChar;
0 commit comments