I saw another question that I was trying to solve as, of any word, always show the first letter and the first vowel, that is:
"mapita" -> ma
"astro" -> ao
function palabra(w){
var toArray = w.split(""),
regex = /aeiou/i,
i = 1,
m = toArray.length,
finalmente = [];
for(;i<m;i++){
if(regex.test(toArray[i])) {
finalmente.push(toArray[0] + toArray[i]).join("");
break;
}
}
return finalmente;
};
console.log(palabra("astronauta"))
But I do not understand what my mistake is, why does not it work?