Is there a way to loop through an array and check if each word is a palindrome, instead of manually passing an argument for each word? If a word is a palindrome, return the word; otherwise, return 0.
var myArray = ['viicc', 'cecarar', 'honda'];
function palindromize(words) {
var p = words.split("").reverse().join("");
if(p === words){
return(words);
} else {
return("0");
}
}
palindromize("viicc");
palindromize("cecarar");
palindromize("honda");