wordprocessor
Advanced tools
+7
-0
@@ -13,4 +13,11 @@ 'use strict'; | ||
| countWord(textBlock) { | ||
| console.log(textBlock.trim().split(' ')); | ||
| if (textBlock.trim().split(' ').length === 1 && textBlock.trim().split(' ')[0] === '') { | ||
| return 0; | ||
| } | ||
| return textBlock.trim().split(' ').length; | ||
| } | ||
| }; |
+1
-1
| { | ||
| "name": "wordprocessor", | ||
| "version": "1.1.0", | ||
| "version": "1.1.1", | ||
| "description": "Process the word", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+24
-0
@@ -67,2 +67,26 @@ 'use strict'; | ||
| it('It correctly counts word of the given roman string', async () => { | ||
| // Given | ||
| const textBlock = 'one'; | ||
| // When | ||
| const wordProcessor = new WordProcessor(); | ||
| const totalCharacters = wordProcessor.countWord(textBlock); | ||
| // Then | ||
| expect(totalCharacters).equal(1); | ||
| }); | ||
| it('It correctly counts word of the given roman string', async () => { | ||
| // Given | ||
| const textBlock = ''; | ||
| // When | ||
| const wordProcessor = new WordProcessor(); | ||
| const totalCharacters = wordProcessor.countWord(textBlock); | ||
| // Then | ||
| expect(totalCharacters).equal(0); | ||
| }); | ||
| it('It correctly counts word of the given nepali string', async () => { | ||
@@ -69,0 +93,0 @@ // Given |
5790
16.9%93
30.99%