Skip to content

shipservlabs/shipserv-code-test-pig-latin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pig Latin Translator

To get started:

  • Run npm install
  • Write your logic in src/pig.ts, aiming to satisfy the test cases.
  • Run tests with npm test (optionally with --watch)
    • Tests are found here

What is Pig Latin?

Pig Latin is a language game where words are altered according to these rules:

  1. For words beginning with consonants:

    • Take all consonants before the first vowel
    • Move them to the end of the word
    • Add "ay" to the end

    Examples:

    "hello" → "ellohay"
    "creating" → "eatingcray"
    
  2. For words beginning with vowels:

    • Simply add "way" to the end of the word

    Example:

    "algorithm" → "algorithmway"
    

Task

Your job is to implement a function that translates a string to Pig Latin.

Requirements:

  • The input string will never be undefined
  • Words will never contain numbers
  • Each word should be transformed according to the rules above

Examples:

"clean code is good" → "eanclay odecay isway oodgay"
"unit tests are the way" → "unitway eststay areway ethay ayway"

Optional Bonus Requirements

Case Preservation

  • Maintain sentence casing in the translated text
  • For ALL CAPS words, the suffix should also be in ALL CAPS ("AY"/"WAY")

Examples with Case Preservation:

"Hello World" → "Ellohay Orldway"
"Very sunny outside Today" → "Eryvay unnysay outsideway Odaytay"
"Roses are RED violets are BLUE" → "Osesray areway EDRAY ioletsvay areway UEBLAY"
"The EARTH is DEFinitELY rounD" → "Ethay EARTHWAY isway EFIniteLYDay oundRay"
"One Apple a DAy keEPs the DOCtor AWAY" → "Oneway Appleway away AYday eePSkay ethay OCTorday AWAYWAY"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors