Sha256: 1918c88450a9113a5c4682dd46fea2016fd38761b9b2e9c0aa4ba76a60398c1d
Contents?: true
Size: 588 Bytes
Versions: 63
Compression:
Stored size: 588 Bytes
Contents
class PigLatin { static translate(phrase: string): string { const words = phrase.split(' ') const translated: string[] = [] words.forEach((word) => { const parts = word.match(/^([^aeiou]?qu|[^aeiou]*)(.+)/) const beginning = parts![1] const ending = parts![2] if (beginning.length === 0) { translated.push(`${word}ay`) } else { translated.push(`${ending}${beginning}ay`) } }) return translated.join(' ') } } export default PigLatin
Version data entries
63 entries across 63 versions & 1 rubygems