Implement isPalindrome in JS

Tags:
Date:

Sunday 24/07/2022

To implement isPalindrome function we can achieve it by implementing another helper function reverseStr().

function reverseStr(str) {
	return str.split('').reverse().join('')
}

And now we can use it for our isPalindrome()

function isPalindrome(str) {
	return str === reverseStr(str)
}

© 2023 Vadim Alakhverdov