We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 842cf9f commit 71d2474Copy full SHA for 71d2474
1 file changed
javascript/5_string-programs/countWords.js
@@ -0,0 +1,10 @@
1
+// 1. Count Words of a String
2
+
3
+// 1. Using split() Method
4
5
+{
6
+ const count = (s) => s.trim().split(/\s+/).length;
7
8
+ const s = "Hello, this is a simple test";
9
+ console.log(count(s));
10
+}
0 commit comments