Skip to content

Commit 0c95f6b

Browse files
word-count added
1 parent 4b8b2a0 commit 0c95f6b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

word_count.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const word = "this is a word";
2+
let count = 0;
3+
for (let i = 0; i < word.length; i++) {
4+
let char = word[i];
5+
if (char == " " && word[i - 1] != " ") {
6+
count++;
7+
}
8+
// console.log(word[i]);
9+
}
10+
count++;
11+
console.log(count);

0 commit comments

Comments
 (0)