Sha256: 6bef662e461de242211bb61c5ff9c00ccdebd1491b68df2f895ea04034f6781e
Contents?: true
Size: 561 Bytes
Versions: 70
Compression:
Stored size: 561 Bytes
Contents
/** * Here is an example solution for the WordCount exercise */ component { function countwords( input ) { return input // Strip out chars we don't care about .reReplaceNoCase( '[^a-z0-9'' ]', '', 'all' ) // Break string into array .listToArray( ' ' ) // Reduce arary into struct of word counts .reduce( function( wordStats, word ){ // Clean quoted words word = word.reReplaceNocase( "^'(.*)'$", "\1" ); // Aggregate word counts wordStats[ word ] = ( wordStats[ word ] ?: 0 ) + 1; return wordStats; }, {} ); } }
Version data entries
70 entries across 69 versions & 1 rubygems