JSFiddle - React, Tailwind, and code Playground

JavaScript

let str = "anna"

const is_p = string =>
    string
        .split("")
        .every((character, index) => character === string[string.length - 1 - index]);

console.log(is_p(str))