Sha256: 783bc21c6c70c08fe9463a1b49d51561ab7801ee104b9de7c8a268e95701fa22
Contents?: true
Size: 632 Bytes
Versions: 72
Compression:
Stored size: 632 Bytes
Contents
/** * Here is an example solution for the PigLatin exercise */ component { function translate( input ) { var response = ''; // Loop over each work return input .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)' ) ) { return word.reReplaceNoCase( '^(ch|squ|qu|thr|th|sch)(.*)', '\2\1ay' ); // Everything else } else { return word.right( -1 ) & word.left( 1 ) & 'ay'; } } ) .toList( ' ' ); } }
Version data entries
72 entries across 71 versions & 1 rubygems