Last active
November 5, 2024 22:27
-
-
Save nblackburn/6f41e0596ef1d5e15d59de4e796ea84c to your computer and use it in GitHub Desktop.
Revisions
-
nblackburn revised this gist
Nov 5, 2024 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,11 @@ const isPalindrome = (value) => { const chars = value.replace(/[^a-zA-Z0-9]/g, '').toLowerCase().split(''); for (let index = 0; index < chars.length / 2; index++) { if (chars[index] !== chars[chars.length - 1 - index]) { return false; } } return true; }; -
nblackburn created this gist
Feb 10, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ Checks if a given word is a palindrome. ## Usage ```javascript const tests = ['hannah', 'anna', 'kayak', 'apple', 'mom', 'wow', 'rotator', 'radar'] tests.forEach((test) => { console.log('IS_PALINDROME', test, isPalindrome(test)); }); ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ const isPalindrome = (value) => { const chars = value.split(''); return chars.every((char, index) => char === chars[chars.length - 1 - index]); };