import * as _ from 'lodash';

export class LetterHistogramService {
    create(sentences: string[]): {[key: string]: number} {
        let letters = _.flatMap(sentences, sentence => sentence.split(''));

        let formattedLetters = _
            .chain(letters)
            .map(s => s.toLowerCase())
            .filter(s => s.match(/[a-z]/i))
            .value();
            
        let initHistogram: {[key: string]: number} = { };
        
        let histogram = _.reduce(formattedLetters, (acc, letter) => {
                acc[letter] = (acc[letter] || 0) + 1;
                return acc;
            }, initHistogram);
            
        return histogram;
    }
};
import * as _ from 'lodash';

export class LetterHistogramService {
    create(sentences: string[]): any {
        let letters = _.flatMap(sentences, sentence => sentence.split(''));

        let formattedLetters = _
            .chain(letters)
            .map(s => s.toLowerCase())
            .filter(s => s.match(/[a-z]/i))
            .value();

        let histogram = _.reduce(formattedLetters, (acc, letter) => {
                acc[letter] = (acc[letter] || 0) + 1;
                return acc;
            }, {});
            
        return histogram;
    }
};
--- 
+++ 
@@ -1,7 +1,7 @@
 import * as _ from 'lodash';
 
 export class LetterHistogramService {
-    create(sentences: string[]): any {
+    create(sentences: string[]): {[key: string]: number} {
         let letters = _.flatMap(sentences, sentence => sentence.split(''));
 
         let formattedLetters = _
@@ -9,11 +9,13 @@
             .map(s => s.toLowerCase())
             .filter(s => s.match(/[a-z]/i))
             .value();
-
+            
+        let initHistogram: {[key: string]: number} = { };
+        
         let histogram = _.reduce(formattedLetters, (acc, letter) => {
                 acc[letter] = (acc[letter] || 0) + 1;
                 return acc;
-            }, {});
+            }, initHistogram);
             
         return histogram;
     }
Make the letter histograms service create method more explicit.
