line 11 of my code (let end = …) returns ‘false’ instead of the expected ‘oovy’
im not sure how to negate a regex so that it returns the opposite of what it was initially written for.
**
function translatePigLatin(str) {
const expression = /^a|^e|^i|^o|^u/i;
const expression2 = /a|e|i|o|u/i;
const expression3 = /\w+(?=a)|\w(?=e)|\w(?=i)|\w(?=o)|\w(?=u)/i
if (expression.test(str)) {
return str + ‘way’
} else if (!expression2.test(str)) {
return str
} else {
let start = str.match(expression3)
let end = !str.match(expression3)
console.log(end)
return end + start + ‘ay’
}
}
console.log(translatePigLatin(“groovy”));
**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36
Challenge: Pig Latin
Link to the challenge: