# Post your Palindrome Checker solutions here!

**URL:** <https://group.classcentral.com/t/post-your-palindrome-checker-solutions-here/35750>\
**Category:** JavaScript Bootcamp\
**Created:** [September 20, 2022, 8:35am UTC](https://group.classcentral.com/t/post-your-palindrome-checker-solutions-here/35750 "2022-09-20T08:35:17Z")\
**Posts on this page:** 9\
**Page:** 3

<div class="post-metadata">

**Author:** ![danc2947636](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@danc2947636](https://group.classcentral.com/u/danc2947636)\
**Post date:** [October 17, 2022, 3:45am UTC](https://group.classcentral.com/t/post-your-palindrome-checker-solutions-here/35750/41 "2022-10-17T03:45:54Z")

</div>

Kept mine simple, all uppercase, removed extra characters, then flipped it around to check for palindrome

```auto
function palindrome(str) {
  var palin = str.toUpperCase().replace(/[\W_]/gi,"");
  var result = palin.split('').reverse().join('');
  return palin === result;
}

palindrome("eye");

console.log(palindrome("level"))

```

---

<div class="post-metadata">

**Author:** ![Timiphil](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/timiphil/32/5367_2.png) [@Timiphil](https://group.classcentral.com/u/Timiphil)\
**Post date:** [October 17, 2022, 9:59am UTC](https://group.classcentral.com/t/post-your-palindrome-checker-solutions-here/35750/42 "2022-10-17T09:59:57Z")

</div>

Nice one Dan,

similar to mine. 👍🏾

---

<div class="post-metadata">

**Author:** ![carlost2672543](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/carlost2672543/32/4162_2.png) [@carlost2672543](https://group.classcentral.com/u/carlost2672543)\
**Post date:** [October 17, 2022, 4:20pm UTC](https://group.classcentral.com/t/post-your-palindrome-checker-solutions-here/35750/43 "2022-10-17T16:20:22Z")

</div>

Welcome @danc2947636

Great solution!!

You also could also dispense with `i` flag and `var` keyword (`const` is enough there).

` const palin = str.toUpperCase().replace(/[\W_]/g, "");`

Keep the good work and good luck!!

---

<div class="post-metadata">

**Author:** ![emdubbsdev](https://avatars.discourse-cdn.com/v4/letter/e/e19adc/32.png) [@emdubbsdev](https://group.classcentral.com/u/emdubbsdev)\
**Post date:** [October 19, 2022, 9:54pm UTC](https://group.classcentral.com/t/post-your-palindrome-checker-solutions-here/35750/44 "2022-10-19T21:54:39Z")

</div>

Hi all! Here’s my code for the palindrome project. I put the guidelines of the rules in comments of my code.

// THE STEPS FOR PROJECT ARE:  
// 1. Receive words (from input/user)  
// 1a. Palindromes are words that can be spelled backwards and forwards; it doesn’t count spacing or punctuation  
// 2. Remove ALL Non-Alphanumberic Characters (punctuation, spaces, symbols)  
// 2a. Turn everything into the same case  
// 3. Check words and confirm that they are/aren’t palindromes  
// 4. Code needs to PASS varying formats of the words. ie: racecar, RaceCar, and race CAR.  
// 5. Codes needs to PASS strings w/ special symbols. ie: 2A3_3a2, 2A3 3a2, and 2\_A3_3#A2y

function removeNonAlpha(str) {  
// step 2  
return str.replace(/[\W\_]/g, “”);  
}  
function sameCaseStr(str) {  
// step 2a  
return str.toString().toLowerCase();  
}  
function reverseString(str) {  
// step 3  
return str.toString().split(“”).reverse().join(“”);  
}  
function palindrome(str) {  
// removes non-alphanumeric characters  
var nonAlphaString = removeNonAlpha(str);

```
// makes case in string all lowercase
var lowerCaseString = sameCaseStr(nonAlphaString);
// check/confirm if words are palindromes
var reservedString = reverseString(lowerCaseString);
// compare string; if the same, return true
console.log(`Is ${lowerCaseString} the palindrome of ${reservedString}?`)

return lowerCaseString === reservedString;

```

}

palindrome(“t en e t”);

---

<div class="post-metadata">

**Author:** ![carlost2672543](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/carlost2672543/32/4162_2.png) [@carlost2672543](https://group.classcentral.com/u/carlost2672543)\
**Post date:** [October 20, 2022, 7:20am UTC](https://group.classcentral.com/t/post-your-palindrome-checker-solutions-here/35750/45 "2022-10-20T07:20:32Z")

</div>

Well done @emdubbsdev!!

Remember that if you select your code and hit the icon **`</>`** it would be easier to visualize your code for everyone.

Keep the good work!! Happy coding!

---

<div class="post-metadata">

**Author:** ![adnanahmad2926951](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@adnanahmad2926951](https://group.classcentral.com/u/adnanahmad2926951)\
**Post date:** [October 21, 2022, 12:08am UTC](https://group.classcentral.com/t/post-your-palindrome-checker-solutions-here/35750/46 "2022-10-21T00:08:36Z")

</div>

I decided to solve it without using methods like .join since at this point we did not learn stuff like that. I will improve the code later.

```auto
function palindrome(str) {
  let result = "";
  //looping through the string
  for (let i = str.length - 1; i >= 0; i--) {
    result = result + str[i];
  }
  //cleaning the string and result to discard special characters 
  let newResult = result.replace(/[^a-z0-9]/gi, "");
  let newStr = str.replace(/[^a-z0-9]/gi, "");
  if (newStr.toLowerCase() !== newResult.toLowerCase()) {
    return false;
  }
  return true;
}

palindrome("not a palindrome");

```

---

<div class="post-metadata">

**Author:** ![carlost2672543](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/carlost2672543/32/4162_2.png) [@carlost2672543](https://group.classcentral.com/u/carlost2672543)\
**Post date:** [October 21, 2022, 11:16am UTC](https://group.classcentral.com/t/post-your-palindrome-checker-solutions-here/35750/47 "2022-10-21T11:16:21Z")

</div>

Hi @adnanahmad2926951

Great job! Yeah! That is a good way to improve your solving problems skills, limiting yourself to the basic JS syntax.

Keep the good work and happy coding!!

---

<div class="post-metadata">

**Author:** ![emdubbsdev](https://avatars.discourse-cdn.com/v4/letter/e/e19adc/32.png) [@emdubbsdev](https://group.classcentral.com/u/emdubbsdev)\
**Post date:** [October 21, 2022, 2:54pm UTC](https://group.classcentral.com/t/post-your-palindrome-checker-solutions-here/35750/48 "2022-10-21T14:54:56Z")

</div>

thanks for letting me know! somehow i missed that button lol

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/ccstudygroup/original/1X/36206832181ed26910a18e33d8bfef087cf661b1.svg) [@system](https://group.classcentral.com/u/system)\
**Post date:** [December 5, 2022, 2:55pm UTC](https://group.classcentral.com/t/post-your-palindrome-checker-solutions-here/35750/49 "2022-12-05T14:55:19Z")

</div>

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.

[Previous page](https://group.classcentral.com/t/post-your-palindrome-checker-solutions-here/35750.md?page=2)
