Pig Latin words without vowels

Pig Latin words without vowels
0

#1

Hi all I can’t get “words without vowels” to work. Where is catch? This is what I have now, In IDE it works. Im using for test word “crypt” and return is “crypt”. Is it right or not?

function translatePigLatin(str) {
    //  let noVowels = str.match(/[^aeiou]/gi)
    let vowels = str.match(/^[aeiou]/)
    let consonant = str.match(/(\w+?)([aeiou]\w+)/) //?
    let cache = []//?
    
    if (vowels) {
        // cache.push(vowels[0]);
         return str  + "way";//?
        }

    if (consonant) {
        cache.push(consonant[1]); //?
        return consonant[2] + cache + "ay"; //?
        }
        // if (noVowels) {
            return str//?
        // }
    }

#2

Hello @StanSkrivanek,

The problem is in the following line and it’s not your fault. The challenge didn’t explicitly precise that words that do not contain any vowels, an ay should be added to them.

If you pass the word tmc to the function, the result should be tmcay.


#3

Oh, ok. I didn’t understand task properly. English is not my mother language and therefore I had never play Pig Latin. It was hard to understand what I have to achieve. Thank you,


#4

You’re welcome.

Good Luck & Happy Coding.


#5

Is done,. Understanding task is crucial, I’ve got a new angle to look on task and my new code is now much simpler. Thanks again


#6

Nice that you done it and got that beautiful window with a big sign of success appearing on your screen.

Good Luck & Happy Coding.