Sha256: b346c5dbf467063b6ca7fa4676fab687092a3ccf956fba56099c18a4d68c5666
Contents?: true
Size: 640 Bytes
Versions: 74
Compression:
Stored size: 640 Bytes
Contents
/** * Here is an example solution for the PigLatin exercise */ component { function translate( phrase ) { var response = ''; // Loop over each work return phrase .listToArray( ' ' ) .map( function( word ) { // Vowel sounds if( word.reFindNoCase( '^(a|e|i|o|u|yt|xr)' ) ) { return word & 'ay'; // Consonate sounds } else if( word.reFindNoCase( '^(ch|squ|qu|thr|th|sch|rh)' ) ) { return word.reReplaceNoCase( '^(ch|squ|qu|thr|th|sch|rh)(.*)', '\2\1ay' ); // Everything else } else { return word.right( -1 ) & word.left( 1 ) & 'ay'; } } ) .toList( ' ' ); } }
Version data entries
74 entries across 74 versions & 1 rubygems