Skip to content

Commit a251adc

Browse files
author
Neelesh Shetty
committed
Easy
1 parent 1e7689f commit a251adc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

21.GetWordCount.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Get Word Count
2+
3+
// Create a function that takes a string and returns the word count. The string will be a sentence.
4+
5+
function getWordCount(str) {
6+
return str.split(" ").length
7+
}
8+
9+
//inputs
10+
console.log(getWordCount("Just an example here move along")) // 6
11+
console.log(getWordCount("This is a test")) // 4
12+
console.log(getWordCount("What an easy task, right")) // 5

0 commit comments

Comments
 (0)