Pig Latin. Why it still write "Should handle words without vowels."

Tell us what’s happening:
So why is my solution wrong? (Sorry, I can’t use links) /javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin

Your code so far

function translatePigLatin(str) {
  let re =/^([^aeiouy])+/i;
  let temp = str.match(re);
  if(temp) {
    let newStr = str.replace(re,'');
    str = newStr + temp[0]+'ay';
  } else {
    str = str+'way';
  return str;


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36.

your code should be general it accept all test case your code seems specific

In the case of the Pig Latin challenge, ‘y’ is not considered a vowel.


Oh thanks. It explains everything

Research the use of {1,} as you need to match a string of consonants and not just the first consonant.
Hope this helps.

{1,} in regex-land is usually written as +

1 Like