Chrome Extension

Check if a string is Palindrome or not using Javascript

The below function written in Javascript can be helpful to check whether a string is Palindrome or not.
function palindrome_checker(str) {
    const converted_str = str.split('').reverse().join('');
    if (str === converted_str) {
        console.log(str + " : String is Palindrome");
    } else {
        console.log(str + " : String is not Palindrome");
    }
}

palindrome_checker('deified');
palindrome_checker('Ankit');
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

What is a Palindrome String

If you reverse a string from right to left or left to right and it remains same then the string will be called Palindrome string. Civic is a palindrome string means if you read it left to right or right to left it will have same characters in same orders.

Live Demo

Was this helpful?
0 Comments