(string)
| 27 | } |
| 28 | |
| 29 | const PalindromeIterative = (string) => { |
| 30 | const _string = string |
| 31 | .toLowerCase() |
| 32 | .replace(/ /g, '') |
| 33 | .replace(/,/g, '') |
| 34 | .replace(/'.'/g, '') |
| 35 | .replace(/:/g, '') |
| 36 | .split('') |
| 37 | |
| 38 | // A word of only 1 character is already a palindrome, so we skip to check it |
| 39 | while (_string.length > 1) { |
| 40 | if (_string.shift() !== _string.pop()) { |
| 41 | return false |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | return true |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * |