Sha256: 89060c2037e5e0c0a5c52eb44fde519b54f0058728a06d9333c7c6d58e5b7991

Contents?: true

Size: 414 Bytes

Versions: 185

Compression:

Stored size: 414 Bytes

Contents

const LANGUAGE_RULES_REGEXP = /^([^aeiou]?qu|[^aeiou]*)(.+)/;

function translateWord(word) {
  const [, beginning, ending] = word.match(LANGUAGE_RULES_REGEXP);

  if (beginning.length === 0) {
    return `${word}ay`;
  }
  return `${ending + beginning}ay`;
}

class PigLatin {
  translate(english) {
    return english
      .split(' ')
      .map(translateWord)
      .join(' ');
  }
}

export default PigLatin;

Version data entries

185 entries across 185 versions & 1 rubygems

Version Path
trackler-2.2.1.38 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.37 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.36 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.35 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.34 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.33 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.32 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.31 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.30 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.29 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.28 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.27 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.26 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.25 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.24 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.23 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.22 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.21 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.20 tracks/ecmascript/exercises/pig-latin/example.js
trackler-2.2.1.19 tracks/ecmascript/exercises/pig-latin/example.js