react Js palindrome program questions and answer for experienced react js developer

How to check for a given word malyalam is palindrome or not.

Here is a sample program how to create a program for word malayalam  to check if it is palindrome or not. 

This is interview question for experienced developers

import React, { useState } from 'react';

const PalindromeChecker = () => {
  const [input, setInput] = useState('');
  const [result, setResult] = useState('');

  const handleChange = (event) => {

  const checkForPalindrome = () => {
    const word = input.toLowerCase().replace(/[^\u0D00-\u0D7F]/g, '');
    const reversedWordString = word.split('').reverse().join('');
    setResult(word === reversedWordString ? 'It is a palindrome' : 'It is not a palindrome');

  return (
      <textarea value={input} onChange={handleChange} />
      <button onClick={checkForPalindrome}>Check Palindrome</button>

export default PalindromeChecker;

Write this program and try to execute it .