2019-03-09 Daily Challenge

What I've done today is Simple Pig Latin in JavaScript.

Problem is misleading and description is like shit. Data is poor.

CodeWars

Problem

Simple Pig Latin

Move the first letter of each word to the end of it, then add "ay" to the end of the word. Leave punctuation marks untouched.

Examples

pigIt('Pig latin is cool'); // igPay atinlay siay oolcay
pigIt('Hello world !');     // elloHay orldway !

Solution

function pigIt(str){
  return str.replace(/([a-zA-Z])([a-zA-Z]*)/gi, "$2$1ay");
}

function pigIt(str){
  return str.replace(/(\w)(\w*)/gi, "$2$1ay");
}