Palindrome Number Program in JavaScript

Today, We want to share with you palindrome number in javascript.In this post we will show you write a javascript program to check whether a string is palindromes or not, hear for how to check whether a given number is palindromes or not in JavaScript. we will give you demo and example for implement.In this post, we will learn about python tkinter button click event with an example.

Read Also:  Angularjs Multiple Controllers in single page

Check number is palindrome or not in JavaScript

Palindrome number

JavaScript code to check palindromes number

<script>
	function Palindrome()
	{
		var rem, temp, final = 0;
		var number = Number(document.getElementById("N").value);

		temp = number;
		while(number>0)
		{
			rem = number%10;
			number = parseInt(number/10);
			final = final*10+rem;
		}
		if(final==temp)
		{
			window.alert("The inputed number is Palindrome");
		}
		else
		{
			window.alert("The inputted number is not palindrome");
		}
	}
</script>

Calling JavaScript function in HTML (HTML, JS Code)

(index.html)

<html>
	<head>
		<script>
			function Palindrome()
			{
				var rem, temp, final = 0;
				var getno = Number(document.getElementById("N").value);

				temp = getno;
				while(getno>0)
				{
					rem = getno%10;
					getno = parseInt(getno/10);
					final = final*10+rem;
				}
				if(final==temp)
				{
					window.alert("The inputed number is Palindrome");
				}
				else
				{
					window.alert("The inputted number is not palindrome");
				}
			}
		</script>
	</head>
	<body>
		<br>
		<h2>Whether a number is Palindromes or not</h2>
		Enter The Number :<input type="text" name="n" id = "N"/>
		<hr color="cyan">
		<br>
		<center><button onClick="Palindrome()">CHECK</button>
	</body>
</html>

I hope you get an idea about count number of palindromes till n in javascript.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.