Intermediate Algorithm Scripting - Pig Latin

I have this code so far but can’t figure out a way to get the correct code. Could someone tell me what I’ve done wrong?

Your code so far

function moveConsonantsToEnd(inputString) {
  // Match consonants using a regex pattern and move them to the end of the string
  const modifiedString = inputString.replace(/([^aeiouAEIOU\s])/, '') 
  if (inputString);
let startWithVowel = /^[aeiouAEIOU]/.test(inputString);
if (startWithVowel){
return modifiedString + "way";
} else {
  return modifiedString + "ay";
}
}
let result = moveConsonantsToEnd("california")
console.log(result)
let testStr = "california"
testStr.replace(/[aeiouAEIOU\s]/)

Your browser information:

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

Challenge: Intermediate Algorithm Scripting - Pig Latin

Link to the challenge:

your not sending the constant to the end of the word before adding the string ‘ay’, you’re just deleting it .

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.