Reputation: 1075
I have been working on a palindrome function (will check if word is spelled the same forward and backwards):
var palinDromes = function(palMap) {
palMap.split(" ").map(function(word) {
var palCheck = (word.toLowerCase() === word.toLowerCase().split("").reverse().join(""));
return palCheck;
});
};
console.log(palinDromes('Hannah speaks English and Malayalam'));
But the output is always undefined. I believe the issue is in the first step, something involving the console.log(palinDrome(...));
transition to palMap
, but I'm not sure what exactly.
The issue might also be that I am not returning palCheck
correctly at the end of the function?
Upvotes: 0
Views: 129
Reputation: 533
var palinDromes = function(palMap) {
return palMap.split(" ").map(function(word) {
var palCheck = (word.toLowerCase() === word.toLowerCase().split("").reverse().join(""));
return palCheck;
});
};
console.log(palinDromes('Hannah speaks English and Malayalam'));
EDIT: I added a return before palMap.split(" ").map(function(word) { ...
Upvotes: 2