Browse Source

fix uppercasing and exception throwing

mightyplow 6 years ago
parent
commit
86a0b01139
1 changed files with 3 additions and 3 deletions
  1. 3 3
      blindtext.js

+ 3 - 3
blindtext.js

@@ -115,11 +115,11 @@ function createSentence (minWords = DEFAULT_MIN_WORDS_PER_SENTENCE, maxWords = D
         sentenceWords.push(
             (i !== 0 && randomInt(0, 3) > 0)
                 ? randomWord
-                : randomWord.toUpperCase()
+                : randomWord[0].toUpperCase() + randomWord.slice(1)
         );
     }
 
-    return sentenceWords.join(' ') + getRandomPunctuationMark;
+    return sentenceWords.join(' ') + getRandomPunctuationMark();
 }
 
 const Unit = {
@@ -134,7 +134,7 @@ const UnitFunction = {
 
 function createText (num, unit = Unit.WORD) {
     if (!UnitFunction.hasOwnProperty(unit)) {
-        throw new Exception('Invalid unit parameter');
+        throw Error('Invalid unit parameter');
     }
 
     const unitCreator = UnitFunction[unit];