function translatePigLatin(str) {
let arr =str.split("");
console.log(arr);
let arr1 = str.search(/a|i|u|y|e|o/i);
console.log(arr1);
if (arr1 == 0){
return arr.join("")+"way";
} else {
let arrSplice = arr.splice(0,arr1 );
console.log(arrSplice);
console.log(arr);
let strLat = arr.concat(arrSplice).join("");
console.log(strLat+"ay");
return strLat+"ay";}
}
translatePigLatin("california");
function translatePigLatin(str) {
const x = str.search(/[aioue]/);
return x > 0
? `${str.slice(x)}${str.slice(0, x)}ay`
: `${str}${x ? '' : 'w'}ay`;
}