Easy to Read Palindrome Checker The Next CEO of Stack OverflowMilliseconds to Time string & Time string to MillisecondsPalindrome Checker Algorithm“ACM ICPC Team” challenge on Hackerrank… Easy?Largest palindrome in a stringTest if a string is a palindromeFinding an equilibrium index in an int arrayEasy Deep Copy of Array JavascriptPalindrome checker in JavaScriptCode Chef RAINBOW PalindromeJavaScript Anagram checker

Solving system of ODEs with extra parameter

How many extra stops do monopods offer for tele photographs?

How to scale a tikZ image which is within a figure environment

Why don't programming languages automatically manage the synchronous/asynchronous problem?

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

Reference request: Grassmannian and Plucker coordinates in type B, C, D

Easy to Read Palindrome Checker

Where do students learn to solve polynomial equations these days?

WOW air has ceased operation, can I get my tickets refunded?

Received an invoice from my ex-employer billing me for training; how to handle?

Why didn't Khan get resurrected in the Genesis Explosion?

Chain wire methods together in Lightning Web Components

unclear about Dynamic Binding

Which one is the true statement?

Is there always a complete, orthogonal set of unitary matrices?

Does soap repel water?

Why isn't acceleration always zero whenever velocity is zero, such as the moment a ball bounces off a wall?

How a 64-bit process virtual address space is divided in Linux?

What does "Its cash flow is deeply negative" mean?

What was the first Unix version to run on a microcomputer?

Why this way of making earth uninhabitable in Interstellar?

is it ok to reduce charging current for li ion 18650 battery?

Flying from Cape Town to England and return to another province

How to get from Geneva Airport to Metabief?



Easy to Read Palindrome Checker



The Next CEO of Stack OverflowMilliseconds to Time string & Time string to MillisecondsPalindrome Checker Algorithm“ACM ICPC Team” challenge on Hackerrank… Easy?Largest palindrome in a stringTest if a string is a palindromeFinding an equilibrium index in an int arrayEasy Deep Copy of Array JavascriptPalindrome checker in JavaScriptCode Chef RAINBOW PalindromeJavaScript Anagram checker










4












$begingroup$


I made a palindrome checker that's supposed to be designed to be simple and easy to read. Please let me know what you think. I believe the time complexity is O(n) but I'm not too sure about that:



Challenge: You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything into the same case (lower or upper case) in order to check for palindromes.



function reverseString(str)
_/g, "").toLowerCase().split(" ").join("");
var array = [];
for(var i = str.length ; i >=0; i--)

array.push(str[i])

return(array.join(""));



reverseString("My age is 0, 0 si ega ym.");

function palindrome(str) _/g, "").toLowerCase().split(" ").join("");
if(str === reverseString(str))

return true;

else

return false;











share|improve this question











$endgroup$











  • $begingroup$
    Are you sure this is working as intended?
    $endgroup$
    – Mast
    2 hours ago










  • $begingroup$
    The test reverseString("My age is 0, 0 si ega ym."); should at least be something like console.log(palindrome(reverseString("My age is 0, 0 si ega ym.")));, and does your challenge ignore spaces? Because if they don't, your example string should return false while it doesn't. Please clarify the exact challenge.
    $endgroup$
    – Mast
    2 hours ago






  • 1




    $begingroup$
    Sorry I updated it
    $endgroup$
    – DreamVision2017
    2 hours ago










  • $begingroup$
    Much better, thank you.
    $endgroup$
    – Mast
    2 hours ago










  • $begingroup$
    Np, let me know if there's anything else that needs to be changed
    $endgroup$
    – DreamVision2017
    2 hours ago















4












$begingroup$


I made a palindrome checker that's supposed to be designed to be simple and easy to read. Please let me know what you think. I believe the time complexity is O(n) but I'm not too sure about that:



Challenge: You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything into the same case (lower or upper case) in order to check for palindromes.



function reverseString(str)
_/g, "").toLowerCase().split(" ").join("");
var array = [];
for(var i = str.length ; i >=0; i--)

array.push(str[i])

return(array.join(""));



reverseString("My age is 0, 0 si ega ym.");

function palindrome(str) _/g, "").toLowerCase().split(" ").join("");
if(str === reverseString(str))

return true;

else

return false;











share|improve this question











$endgroup$











  • $begingroup$
    Are you sure this is working as intended?
    $endgroup$
    – Mast
    2 hours ago










  • $begingroup$
    The test reverseString("My age is 0, 0 si ega ym."); should at least be something like console.log(palindrome(reverseString("My age is 0, 0 si ega ym.")));, and does your challenge ignore spaces? Because if they don't, your example string should return false while it doesn't. Please clarify the exact challenge.
    $endgroup$
    – Mast
    2 hours ago






  • 1




    $begingroup$
    Sorry I updated it
    $endgroup$
    – DreamVision2017
    2 hours ago










  • $begingroup$
    Much better, thank you.
    $endgroup$
    – Mast
    2 hours ago










  • $begingroup$
    Np, let me know if there's anything else that needs to be changed
    $endgroup$
    – DreamVision2017
    2 hours ago













4












4








4





$begingroup$


I made a palindrome checker that's supposed to be designed to be simple and easy to read. Please let me know what you think. I believe the time complexity is O(n) but I'm not too sure about that:



Challenge: You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything into the same case (lower or upper case) in order to check for palindromes.



function reverseString(str)
_/g, "").toLowerCase().split(" ").join("");
var array = [];
for(var i = str.length ; i >=0; i--)

array.push(str[i])

return(array.join(""));



reverseString("My age is 0, 0 si ega ym.");

function palindrome(str) _/g, "").toLowerCase().split(" ").join("");
if(str === reverseString(str))

return true;

else

return false;











share|improve this question











$endgroup$




I made a palindrome checker that's supposed to be designed to be simple and easy to read. Please let me know what you think. I believe the time complexity is O(n) but I'm not too sure about that:



Challenge: You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything into the same case (lower or upper case) in order to check for palindromes.



function reverseString(str)
_/g, "").toLowerCase().split(" ").join("");
var array = [];
for(var i = str.length ; i >=0; i--)

array.push(str[i])

return(array.join(""));



reverseString("My age is 0, 0 si ega ym.");

function palindrome(str) _/g, "").toLowerCase().split(" ").join("");
if(str === reverseString(str))

return true;

else

return false;








javascript algorithm programming-challenge array






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago







DreamVision2017

















asked 2 hours ago









DreamVision2017DreamVision2017

464




464











  • $begingroup$
    Are you sure this is working as intended?
    $endgroup$
    – Mast
    2 hours ago










  • $begingroup$
    The test reverseString("My age is 0, 0 si ega ym."); should at least be something like console.log(palindrome(reverseString("My age is 0, 0 si ega ym.")));, and does your challenge ignore spaces? Because if they don't, your example string should return false while it doesn't. Please clarify the exact challenge.
    $endgroup$
    – Mast
    2 hours ago






  • 1




    $begingroup$
    Sorry I updated it
    $endgroup$
    – DreamVision2017
    2 hours ago










  • $begingroup$
    Much better, thank you.
    $endgroup$
    – Mast
    2 hours ago










  • $begingroup$
    Np, let me know if there's anything else that needs to be changed
    $endgroup$
    – DreamVision2017
    2 hours ago
















  • $begingroup$
    Are you sure this is working as intended?
    $endgroup$
    – Mast
    2 hours ago










  • $begingroup$
    The test reverseString("My age is 0, 0 si ega ym."); should at least be something like console.log(palindrome(reverseString("My age is 0, 0 si ega ym.")));, and does your challenge ignore spaces? Because if they don't, your example string should return false while it doesn't. Please clarify the exact challenge.
    $endgroup$
    – Mast
    2 hours ago






  • 1




    $begingroup$
    Sorry I updated it
    $endgroup$
    – DreamVision2017
    2 hours ago










  • $begingroup$
    Much better, thank you.
    $endgroup$
    – Mast
    2 hours ago










  • $begingroup$
    Np, let me know if there's anything else that needs to be changed
    $endgroup$
    – DreamVision2017
    2 hours ago















$begingroup$
Are you sure this is working as intended?
$endgroup$
– Mast
2 hours ago




$begingroup$
Are you sure this is working as intended?
$endgroup$
– Mast
2 hours ago












$begingroup$
The test reverseString("My age is 0, 0 si ega ym."); should at least be something like console.log(palindrome(reverseString("My age is 0, 0 si ega ym.")));, and does your challenge ignore spaces? Because if they don't, your example string should return false while it doesn't. Please clarify the exact challenge.
$endgroup$
– Mast
2 hours ago




$begingroup$
The test reverseString("My age is 0, 0 si ega ym."); should at least be something like console.log(palindrome(reverseString("My age is 0, 0 si ega ym.")));, and does your challenge ignore spaces? Because if they don't, your example string should return false while it doesn't. Please clarify the exact challenge.
$endgroup$
– Mast
2 hours ago




1




1




$begingroup$
Sorry I updated it
$endgroup$
– DreamVision2017
2 hours ago




$begingroup$
Sorry I updated it
$endgroup$
– DreamVision2017
2 hours ago












$begingroup$
Much better, thank you.
$endgroup$
– Mast
2 hours ago




$begingroup$
Much better, thank you.
$endgroup$
– Mast
2 hours ago












$begingroup$
Np, let me know if there's anything else that needs to be changed
$endgroup$
– DreamVision2017
2 hours ago




$begingroup$
Np, let me know if there's anything else that needs to be changed
$endgroup$
– DreamVision2017
2 hours ago










2 Answers
2






active

oldest

votes


















1












$begingroup$

Too much code.



  • You can return a boolean

Note that the positions of and



 if(str === reverseString(str)) 
return true;
else
return false;



Becomes



 return str === reverseString(str);


  • You can remove whites spaces and commas etc with regExp /W/g


  • Array has a reverse function which you can use rather than do it manually.


  • You should reverse the string in the function.


  • Strings are iterate-able so you can convert a string to an array with [...str]


Example



function isPalindrome(str) 
str = str.replace(/W/g,"").toLowerCase();
return str === [...str].reverse().join("");






share|improve this answer









$endgroup$




















    1












    $begingroup$

    Time complexity



    Your time complexity is linear, although you can save a few traversals over the string and lower the constant factor.



    Repeated code



    One rule of thumb in a code review is to look for repeated code, which harms maintainability and readability. Notice that the line



    str.replace(/[^ws]|_/g, "").toLowerCase().split(" ").join("");


    appears in two places in the code. If you decide to change one to accept a different regex but forget to change the other one, you've introduced a potentially subtle bug into your program. Move this to its own function to avoid duplication.



    Use accurate function names; use builtins



    reverseString is a confusing function: it does more than reversing a string as advertised: it also strips whitespace and punctuation, which would be very surprising if I called this function as a user of your library without knowing its internals. All functions should operate as black boxes that perform one task advertised in their name.



    The array prototype already has a reverse() function, so there's no need to write this out by hand.



    Avoid unnecessary verbosity



    The code:



     if(str === reverseString(str))

    return true;

    else

    return false;



    is clearer written as return str === reverseString(str);, which says "return the logical result of comparing str and its reversal".



    Improve the regex to match your specification



    The .split(" ").join("") operation is the same as simply including spaces in your regex substitution from " " to "". If you wish to remove all non-alphanumeric characters, a regex like /[^a-zd]/gi reflects your written specification accurately (or use W if you don't mind including underscores).



    Style remarks



    • JS uses K&R braces instead of Allman by convention.

    • Add a blank line above for and if blocks to ease vertical congestion.

    • Add a space around keywords and operators like for( and >=0, which are clearer as for ( and >= 0.

    • No need for parentheses around a return value.


    • array.push(str[i]) is missing a semicolon.

    A rewrite






    const palindrome = str => 
    str = str.replace(/[^a-zd]/gi, "").toLowerCase();
    return str === str.split("").reverse().join("");
    ;

    console.log(palindrome("My age is 0, 0 si ega ym."));








    share|improve this answer











    $endgroup$













      Your Answer





      StackExchange.ifUsing("editor", function ()
      return StackExchange.using("mathjaxEditing", function ()
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
      );
      );
      , "mathjax-editing");

      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "196"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216534%2feasy-to-read-palindrome-checker%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1












      $begingroup$

      Too much code.



      • You can return a boolean

      Note that the positions of and



       if(str === reverseString(str)) 
      return true;
      else
      return false;



      Becomes



       return str === reverseString(str);


      • You can remove whites spaces and commas etc with regExp /W/g


      • Array has a reverse function which you can use rather than do it manually.


      • You should reverse the string in the function.


      • Strings are iterate-able so you can convert a string to an array with [...str]


      Example



      function isPalindrome(str) 
      str = str.replace(/W/g,"").toLowerCase();
      return str === [...str].reverse().join("");






      share|improve this answer









      $endgroup$

















        1












        $begingroup$

        Too much code.



        • You can return a boolean

        Note that the positions of and



         if(str === reverseString(str)) 
        return true;
        else
        return false;



        Becomes



         return str === reverseString(str);


        • You can remove whites spaces and commas etc with regExp /W/g


        • Array has a reverse function which you can use rather than do it manually.


        • You should reverse the string in the function.


        • Strings are iterate-able so you can convert a string to an array with [...str]


        Example



        function isPalindrome(str) 
        str = str.replace(/W/g,"").toLowerCase();
        return str === [...str].reverse().join("");






        share|improve this answer









        $endgroup$















          1












          1








          1





          $begingroup$

          Too much code.



          • You can return a boolean

          Note that the positions of and



           if(str === reverseString(str)) 
          return true;
          else
          return false;



          Becomes



           return str === reverseString(str);


          • You can remove whites spaces and commas etc with regExp /W/g


          • Array has a reverse function which you can use rather than do it manually.


          • You should reverse the string in the function.


          • Strings are iterate-able so you can convert a string to an array with [...str]


          Example



          function isPalindrome(str) 
          str = str.replace(/W/g,"").toLowerCase();
          return str === [...str].reverse().join("");






          share|improve this answer









          $endgroup$



          Too much code.



          • You can return a boolean

          Note that the positions of and



           if(str === reverseString(str)) 
          return true;
          else
          return false;



          Becomes



           return str === reverseString(str);


          • You can remove whites spaces and commas etc with regExp /W/g


          • Array has a reverse function which you can use rather than do it manually.


          • You should reverse the string in the function.


          • Strings are iterate-able so you can convert a string to an array with [...str]


          Example



          function isPalindrome(str) 
          str = str.replace(/W/g,"").toLowerCase();
          return str === [...str].reverse().join("");







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 30 mins ago









          Blindman67Blindman67

          9,0811621




          9,0811621























              1












              $begingroup$

              Time complexity



              Your time complexity is linear, although you can save a few traversals over the string and lower the constant factor.



              Repeated code



              One rule of thumb in a code review is to look for repeated code, which harms maintainability and readability. Notice that the line



              str.replace(/[^ws]|_/g, "").toLowerCase().split(" ").join("");


              appears in two places in the code. If you decide to change one to accept a different regex but forget to change the other one, you've introduced a potentially subtle bug into your program. Move this to its own function to avoid duplication.



              Use accurate function names; use builtins



              reverseString is a confusing function: it does more than reversing a string as advertised: it also strips whitespace and punctuation, which would be very surprising if I called this function as a user of your library without knowing its internals. All functions should operate as black boxes that perform one task advertised in their name.



              The array prototype already has a reverse() function, so there's no need to write this out by hand.



              Avoid unnecessary verbosity



              The code:



               if(str === reverseString(str))

              return true;

              else

              return false;



              is clearer written as return str === reverseString(str);, which says "return the logical result of comparing str and its reversal".



              Improve the regex to match your specification



              The .split(" ").join("") operation is the same as simply including spaces in your regex substitution from " " to "". If you wish to remove all non-alphanumeric characters, a regex like /[^a-zd]/gi reflects your written specification accurately (or use W if you don't mind including underscores).



              Style remarks



              • JS uses K&R braces instead of Allman by convention.

              • Add a blank line above for and if blocks to ease vertical congestion.

              • Add a space around keywords and operators like for( and >=0, which are clearer as for ( and >= 0.

              • No need for parentheses around a return value.


              • array.push(str[i]) is missing a semicolon.

              A rewrite






              const palindrome = str => 
              str = str.replace(/[^a-zd]/gi, "").toLowerCase();
              return str === str.split("").reverse().join("");
              ;

              console.log(palindrome("My age is 0, 0 si ega ym."));








              share|improve this answer











              $endgroup$

















                1












                $begingroup$

                Time complexity



                Your time complexity is linear, although you can save a few traversals over the string and lower the constant factor.



                Repeated code



                One rule of thumb in a code review is to look for repeated code, which harms maintainability and readability. Notice that the line



                str.replace(/[^ws]|_/g, "").toLowerCase().split(" ").join("");


                appears in two places in the code. If you decide to change one to accept a different regex but forget to change the other one, you've introduced a potentially subtle bug into your program. Move this to its own function to avoid duplication.



                Use accurate function names; use builtins



                reverseString is a confusing function: it does more than reversing a string as advertised: it also strips whitespace and punctuation, which would be very surprising if I called this function as a user of your library without knowing its internals. All functions should operate as black boxes that perform one task advertised in their name.



                The array prototype already has a reverse() function, so there's no need to write this out by hand.



                Avoid unnecessary verbosity



                The code:



                 if(str === reverseString(str))

                return true;

                else

                return false;



                is clearer written as return str === reverseString(str);, which says "return the logical result of comparing str and its reversal".



                Improve the regex to match your specification



                The .split(" ").join("") operation is the same as simply including spaces in your regex substitution from " " to "". If you wish to remove all non-alphanumeric characters, a regex like /[^a-zd]/gi reflects your written specification accurately (or use W if you don't mind including underscores).



                Style remarks



                • JS uses K&R braces instead of Allman by convention.

                • Add a blank line above for and if blocks to ease vertical congestion.

                • Add a space around keywords and operators like for( and >=0, which are clearer as for ( and >= 0.

                • No need for parentheses around a return value.


                • array.push(str[i]) is missing a semicolon.

                A rewrite






                const palindrome = str => 
                str = str.replace(/[^a-zd]/gi, "").toLowerCase();
                return str === str.split("").reverse().join("");
                ;

                console.log(palindrome("My age is 0, 0 si ega ym."));








                share|improve this answer











                $endgroup$















                  1












                  1








                  1





                  $begingroup$

                  Time complexity



                  Your time complexity is linear, although you can save a few traversals over the string and lower the constant factor.



                  Repeated code



                  One rule of thumb in a code review is to look for repeated code, which harms maintainability and readability. Notice that the line



                  str.replace(/[^ws]|_/g, "").toLowerCase().split(" ").join("");


                  appears in two places in the code. If you decide to change one to accept a different regex but forget to change the other one, you've introduced a potentially subtle bug into your program. Move this to its own function to avoid duplication.



                  Use accurate function names; use builtins



                  reverseString is a confusing function: it does more than reversing a string as advertised: it also strips whitespace and punctuation, which would be very surprising if I called this function as a user of your library without knowing its internals. All functions should operate as black boxes that perform one task advertised in their name.



                  The array prototype already has a reverse() function, so there's no need to write this out by hand.



                  Avoid unnecessary verbosity



                  The code:



                   if(str === reverseString(str))

                  return true;

                  else

                  return false;



                  is clearer written as return str === reverseString(str);, which says "return the logical result of comparing str and its reversal".



                  Improve the regex to match your specification



                  The .split(" ").join("") operation is the same as simply including spaces in your regex substitution from " " to "". If you wish to remove all non-alphanumeric characters, a regex like /[^a-zd]/gi reflects your written specification accurately (or use W if you don't mind including underscores).



                  Style remarks



                  • JS uses K&R braces instead of Allman by convention.

                  • Add a blank line above for and if blocks to ease vertical congestion.

                  • Add a space around keywords and operators like for( and >=0, which are clearer as for ( and >= 0.

                  • No need for parentheses around a return value.


                  • array.push(str[i]) is missing a semicolon.

                  A rewrite






                  const palindrome = str => 
                  str = str.replace(/[^a-zd]/gi, "").toLowerCase();
                  return str === str.split("").reverse().join("");
                  ;

                  console.log(palindrome("My age is 0, 0 si ega ym."));








                  share|improve this answer











                  $endgroup$



                  Time complexity



                  Your time complexity is linear, although you can save a few traversals over the string and lower the constant factor.



                  Repeated code



                  One rule of thumb in a code review is to look for repeated code, which harms maintainability and readability. Notice that the line



                  str.replace(/[^ws]|_/g, "").toLowerCase().split(" ").join("");


                  appears in two places in the code. If you decide to change one to accept a different regex but forget to change the other one, you've introduced a potentially subtle bug into your program. Move this to its own function to avoid duplication.



                  Use accurate function names; use builtins



                  reverseString is a confusing function: it does more than reversing a string as advertised: it also strips whitespace and punctuation, which would be very surprising if I called this function as a user of your library without knowing its internals. All functions should operate as black boxes that perform one task advertised in their name.



                  The array prototype already has a reverse() function, so there's no need to write this out by hand.



                  Avoid unnecessary verbosity



                  The code:



                   if(str === reverseString(str))

                  return true;

                  else

                  return false;



                  is clearer written as return str === reverseString(str);, which says "return the logical result of comparing str and its reversal".



                  Improve the regex to match your specification



                  The .split(" ").join("") operation is the same as simply including spaces in your regex substitution from " " to "". If you wish to remove all non-alphanumeric characters, a regex like /[^a-zd]/gi reflects your written specification accurately (or use W if you don't mind including underscores).



                  Style remarks



                  • JS uses K&R braces instead of Allman by convention.

                  • Add a blank line above for and if blocks to ease vertical congestion.

                  • Add a space around keywords and operators like for( and >=0, which are clearer as for ( and >= 0.

                  • No need for parentheses around a return value.


                  • array.push(str[i]) is missing a semicolon.

                  A rewrite






                  const palindrome = str => 
                  str = str.replace(/[^a-zd]/gi, "").toLowerCase();
                  return str === str.split("").reverse().join("");
                  ;

                  console.log(palindrome("My age is 0, 0 si ega ym."));








                  const palindrome = str => 
                  str = str.replace(/[^a-zd]/gi, "").toLowerCase();
                  return str === str.split("").reverse().join("");
                  ;

                  console.log(palindrome("My age is 0, 0 si ega ym."));





                  const palindrome = str => 
                  str = str.replace(/[^a-zd]/gi, "").toLowerCase();
                  return str === str.split("").reverse().join("");
                  ;

                  console.log(palindrome("My age is 0, 0 si ega ym."));






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 4 mins ago

























                  answered 42 mins ago









                  ggorlenggorlen

                  393111




                  393111



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Code Review Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      Use MathJax to format equations. MathJax reference.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216534%2feasy-to-read-palindrome-checker%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Best approach to update all entries in a list that is paginated?Best way to add items to a paginated listChoose Your Country: Best Usability approachUpdate list when a user is viewing the list without annoying themWhen would the best day to update your webpage be?What should happen when I add a Row to a paginated, sorted listShould I adopt infinite scrolling or classical pagination?How to show user that page objects automatically updateWhat is the best location to locate the comments section in a list pageBest way to combine filtering and selecting items in a listWhen one of two inputs must be updated to satisfy a consistency criteria, which should you update (if at all)?

                      Вунгтау (аеропорт) Загальні відомості | Див. також | Посилання | Навігаційне меню10°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.0833310°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.083337731608Vinh AirportVinh airport facelift improves serviceвиправивши або дописавши їївиправивши або дописавши їїр

                      Тонконіг бульбистий Зміст Опис | Поширення | Екологія | Господарське значення | Примітки | Див. також | Література | Джерела | Посилання | Навігаційне меню1114601320038-241116202404kew-435458Poa bulbosaЭлектронный каталог сосудистых растений Азиатской России [Електронний каталог судинних рослин Азіатської Росії]Малышев Л. Л. Дикие родичи культурных растений. Poa bulbosa L. - Мятлик луковичный. [Малишев Л. Л. Дикі родичи культурних рослин. Poa bulbosa L. - Тонконіг бульбистий.]Мятлик (POA) Сем. Злаки (Мятликовые) [Тонконіг (POA) Род. Злаки (Тонконогові)]Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Description from Flora of China) [Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Опис від Флора Китаю)]Poa bulbosa L. – lipnice cibulkatá / lipnica cibulkatáPoa bulbosa в базі даних Poa bulbosa на сайті Poa bulbosa в базі даних «Global Biodiversity Information Facility» (GBIF)Poa bulbosa в базі даних «Euro + Med PlantBase» — інформаційному ресурсі для Євро-середземноморського розмаїття рослинPoa bulbosa L. на сайті «Плантариум»