How to negate regex .match

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)
return end + start + ‘ay’


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:

try to fix your quotes (" “)first. your strings are not strings and the rest is not being recognized because of this.
and if your wanting to return the opposite of a string your looking for.
well there are several ways you can do this. the easier one to explain would be something like a function chain or a loop.
. reverse()
.join("") ;

if (!1 == 0 ) {
return “if one(1) does not equal zero(0)”
these might help

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