GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — JavaScript/String/CheckPalindrome.js at master · Randomlyclueless/JavaScript Expand file tree/ Copy pathCheckPalindrome.jsMore file actions 17 lines (16 loc) · 603 Bytes / Copy pathCheckPalindrome.jsFile metadata and controls17 lines (16 loc) · 603 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 // Palindrome check is case sensitive; i.e., Aba is not a palindrome // input is a string const checkPalindrome = (str) => { // check that input is a string if (typeof str !== 'string') { return 'Not a string' } if (str.length === 0) { return 'Empty string' } // Reverse only works with array, thus convert the string to array, reverse it and convert back to string // return as palindrome if the reversed string is equal to the input string const reversed = [...str].reverse().join('') return str === reversed ? 'Palindrome' : 'Not a Palindrome' } export { checkPalindrome } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |