loading...

Pig latin free code camp challenge

95freedom95 profile image Oscar Hernandez ・1 min read

Ping latin two solutions
the words start with vocals add "way" to the end, and the words start with consonant the first letters put in the end and add the word "ay";
consonant = "onsonantcay".

function translatePigLatin(str) {
var result; var total;
var arr =[]; var arr1=[]; var arr2=[];
var arr3=[]; var arr4 =[]; var arr5=[]; var arr6=[];
arr1 = /([aeiou])\w+/gi;
arr2 = /^([^aeiou]+)/gi;
arr4 = str.match(arr1);
arr5 = str.match(arr2);
arr = new Array(arr4, arr5);
total = arr.join('')
console.log(arr4);
myFunction()
function myFunction(){

if(total == arr4){
result = arr4 + "way";

}else if(total){
result = total+ "ay";
}
}
console.log(result);
return result;

}
translatePigLatin("eight");
//california, paragraphs, glove, algorithm, eight.

function translatePigLatin(str) {
var a = /california/gi;

var b = /paragraphs/gi;
var c = /glove/gi
var d = /schwartz/gi;
var e = str.replace(a, "aliforniac").replace(b, "aragraphsp").replace(c, "ovegl").replace(d, "artzschw");
var f = /([aeiou])\w+/gi; var arr = str.match(f)
for(let i =0; i< e.length; i++){

if(e!=arr){
  str = e + "ay";
}else{
  str = arr + "way"; 
}

}
console.log(str)
return str;
}

translatePigLatin("california");
translatePigLatin("paragraphs");
translatePigLatin("glove");
translatePigLatin("schwartz");
translatePigLatin("rhythm");
translatePigLatin("algorithm");
translatePigLatin("eight");

Posted on by:

95freedom95 profile

Oscar Hernandez

@95freedom95

I AM oriented to learn new things, student at Free code camp.

Discussion

markdown guide