I need a function that takes a characters array and returns the same array but reversed and without the "*" character.
I have tried a lot of codes without success. This was my last attempt (sorry if doesn't have sense, I am learning JS)
function laClaveSecreta(carac){
let new_str=[];
for(i=0;i<carac.length;i++){
if(carac[i]==="*"){
new_str=new_str.push(carac.replace(/[*\s]/g, ''));
}
return new_str.reverse();
}
}
//Running the function with this parameter
laClaveSecreta( [ "s", "*", "e", "n", "u", "l", " ", "s", "*", "e", " ", "a", "í", "*", "d", " ", "l", "*", "E", "*"] )
//Result I am looking for
"El día es lunes"
replaceon the entire string.carac.reverse().join("").replace(/[*]/g, "")