Palindrome Number Program in Javascript

Create a javascript program to perform a palindrome test. Before understanding the logic of palindrome in javascript we need to understand what is a palindrome. Below is the definition of palindrome with examples. JavaScript Program to find Palindrome pwb, palindrome javascript by programmingwithbasics, Javascript Palindrome Check.

What is palindrome

A palindrome is a word, phrase, number, or another sequence of characters which reads the same backward or forward. Allowances may be made for adjustments to capital letters, punctuation, and word dividers. Examples in English include "a man, a plan, a canal, Panama!", "Amor, Roma", "race car", "stack cats", "step on no pets", "taco cat", "put it up", "was it a car or a cat i saw?" and "no 'x' in Nixon".

Create A HTML WebPage Using JAVASCRIPT For Check Given String In Palindrome Or Not

In Hindi:- "उल्टा सीधा एक समान" or "Ulta Seedha Ek Samaan"

Javascript Palindrome Code start from here

 <meta charset = "UTF-8">
 <style type="text/css">
   font:10px sans-serif;

 <script type="text/javascript">
  function palindrome()
   var initial = prompt("Please enter a 5 digit string to check whether it is a palindrome:", "");
   var palin = new Array();
   while (initial.length != 5)
    alert("You did not enter a 5 character digit! All palindromes that this calculator can solve are 5 digits!")
    initial = prompt("Please enter a 5 digit string to check whether it is a palindrome:", "");
   for (var i = 0; i <= initial.length -1; i++) {
    palin[i] = initial.charAt(i);
   if (palin[0] == palin[4])
    if (palin[1] == palin[3])
     document.write("The number that you entered was " + initial + ".");
     document.write("<br>This number is a palindrome!")
    document.write("The number that you entered was " + initial + ".");
    document.write("<br>This number is NOT a palindrome!")
<body align="center" bgcolor="aqua">
 <p><h2> Enter a 5 digit string to check whether an the string is a palindrome.</p></h2><br>
 <p><h2> A palindrome is a number that reads the same backwards and forwards. </h2></p1>
 <input type = "button" id = "palindrome" value = "Click to start the program"  onclick = "palindrome();" />


Javascript Palindrome

Javascript Palindrome taking input

Javascript Palindrome test output of a number

Number Is Not Palindrome Example

Number is not Palindrome in Javascript output

Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me