I just finished writing Palindrome, it works correctly but i just wanted to ask for someones opinion on how i did it.

function isAlpha(word){

    let alphabets = "abcdefghijklmnopqrstuvwxyz"

    if (alphabets.indexOf(word) != -1){

        return true;



        return false;



const palindromes = function(){

    tmpArr = Array.from(arguments);

    result = {};

    tmpArr.forEach(function (value) {

        let splitWord = value.toLowerCase().split(' ');

        let word = '';

        for (parts of splitWord){

            for (let i = 0; i < parts.length; i++){


                    word += parts[i];


                else {





        let reversedWord = '';

        for(let i = word.length - 1; i >= 0; i--){

            reversedWord += word[i];


        if (word === reversedWord){

            result[value] = true;


        else {


            result[value] = false;



    return result;


So i basically first created a function(isAlpha) that checks if a given character is an alphabet or not and returns true if it is.
And since my palindromes function handles multiple arguments, i returned the result as an object, is that okay to do?.

Personally I would have the toLowerCase be part of the isAlpha function, as written the isAlpha function will return false for capital letters. The way you’ve structred the palindrome function (using isAlpha after toLowerCase) means it’s not a problem, but the rearrangment makes more logical sense to me.

I think palindrome should be a function, not a constant. The code was not running for me with palindrome as a constant so I’m not sure how it worked for you.

You don’t need to split (let splitword = ) because it’s already an array from a few lines up, but you will have to refactor your latter for line if you change that.

1 Like

I see, I actually got that from the Odinproject github repository, it was written like:-
Const palindrome = function…
It was kind of pain in the a*s to make it work like that, but I thought maybe that was an important part of this excercise?.
But yeah thanks for the advice!