Palindrome Challenge - My solution - Feeling humbled

Palindrome Challenge - My solution - Feeling humbled


This challenge was the first “challenging” one so far. After I came up with a working solution I went back and read the “hint” section to try to find different ways to accomplish it. I see that I used some extra variables and could have combined the split, reverse, join methods.

This challenge took around 3 hours and it kicked my behind…
I guess I would register this as a basic solution from looking at the examples.

function palindrome(str) {
  var lowerCase = str.toLocaleLowerCase().replace(/[^A-Z0-9]+/ig, '');
  var splited = lowerCase.split('');
  var reversed = splited.reverse();
  var joined = reversed.join('').replace(/[^A-Z0-9]+/ig, '');
  var a = lowerCase;
  var b = joined;
 if (a !== b){
    return false;
    return true;



I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


But you did it. That’s the goal. You’ve even analyzed how you can improve your code. Things are looking good.