Pig Latin doubt

Hello everyone. Can you find what’s wrong in my code here? The output is:

// aragraphsp,pay

function translatePigLatin(str) {

let consonantRegex = /(^[^aeiou]+)/
let myConsonants = str.match(consonantRegex)

if (consonantRegex.test(str)) {
  return str.replace(consonantRegex, '').concat(myConsonants, 'ay')
else {
  str += 'way'
  return str



Challenge: Pig Latin

Link to the challenge:

.concat() returns an array. That’s why you are seeing a comma when you print the returned value.

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