MCPcopy Index your code
hub / github.com/TheAlgorithms/JavaScript / PalindromeIterative

Function PalindromeIterative

Maths/Palindrome.js:29–46  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

27}
28
29const 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 *

Callers 1

Palindrome.test.jsFile · 0.90

Calls 1

popMethod · 0.45

Tested by

no test coverage detected