Skip to content

Commit 5ec8680

Browse files
authored
Update and rename Palindrome Checker.js to Palindrome Checker.md
1 parent 09823e9 commit 5ec8680

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*JavaScript Algorithms and Data Structures Projects: Palindrome Checker
1+
JavaScript Algorithms and Data Structures Projects: Palindrome Checker
22
Return true if the given string is a palindrome. Otherwise, return false.
33

44
A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.
@@ -8,11 +8,10 @@ You'll need to remove all non-alphanumeric characters (punctuation, spaces and s
88

99
We'll pass strings with varying formats, such as "racecar", "RaceCar", and "race CAR" among others.
1010

11-
We'll also pass strings with special symbols, such as "2A3*3a2", "2A3 3a2", and "2_A3*3#A2"./**/
12-
11+
We'll also pass strings with special symbols, such as "2A3*3a2", "2A3 3a2", and "2_A3*3#A2".
1312

13+
```js
1414
function palindrome(str) {
15-
// Good luck!
1615
str = str.replace(/[\W_]/g, '').toLowerCase();
1716

1817
let rev = str.split('').reverse().join('');
@@ -25,10 +24,10 @@ function palindrome(str) {
2524

2625

2726
palindrome("eye");
27+
```js
2828
29-
30-
/*[ and ] are the start and end of a character set.
31-
\W means "non-word", as opposed to \w which will match a word.
32-
_ is the "_" character.
33-
/ mark the beginning and end of a regular expression.
34-
g means it's a global search.*/
29+
* [ and ] are the start and end of a character set.
30+
* \W means "non-word", as opposed to \w which will match a word.
31+
* _ is the "_" character.
32+
* / mark the beginning and end of a regular expression.
33+
* g means it's a global search.

0 commit comments

Comments
 (0)