Check if a String is a Palindrome using node js

// Function to check if a string is a palindrome
function isPalindrome(str) {
  const reversed = str.split('').reverse().join('');
  return str === reversed;
}

// Example usage
const isPalindromeResult = isPalindrome('level');
console.log(isPalindromeResult);

 

Post your Answer