function translatePigLatin(str) {
	let newStr = "";
	let vowelRgx = /[aeiou]/gi;
	let vowels = ["a", "e", "i", "o", "u"];
	for (let v = 0; v < vowels.length; v++) {
		if (str.startsWith(vowels[v])) {
			newStr = str + "way";
		}
	}
	
	if (str.match(vowelRgx) === null) {
		newStr = str + "ay";
	} else {
		newStr = str.replace(/([bcdfghjklmnpqrstvwxyz]+)(\w+)/, replacer);
	}
	return newStr;
}
// Input strings are guaranteed to be English words in all lowercase.
Input strings are guaranteed to be English words in all lowercase.
Input strings are guaranteed to be English words in all lowercase .
function translatePigLatin(str) {
	let newStr = "";
	let vowelRgx = /[aeiou]/gi;
	let vowels = ["a", "e", "i", "o", "u"];
	for (let v = 0; v < vowels.length; v++) {
		if (str.startsWith(vowels[v])) {
			newStr = str + "way";
		}
	}
	if (str.match(vowelRgx) === null) {
		newStr = str + "ay";
	} else {
		newStr = str.replace(/([bcdfghjklmnpqrstvwxyz]+)(\w+)/, replacer);
	}
	return newStr;
}
function translatePigLatin ( str ) { let newStr = "" ; let vowelRgx = / [aeiou] / gi ; let vowels = [ "a" , "e" , "i" , "o" , "u" ] ; for ( let v = 0 ; v < vowels . length ; v ++ ) { if ( str . startsWith ( vowels [ v ] ) ) { newStr = str + "way" ; } } if ( str . match ( vowelRgx ) === null ) { newStr = str + "ay" ; } else { newStr = str . replace ( / ([bcdfghjklmnpqrstvwxyz]+)(\w+) / , replacer ) ; } return newStr ; }
Input strings are guaranteed to be English words in all lowercase.
Input strings are guaranteed to be English words in all lowercase .