Write a JavaScript program to check whether given number is Palindrome or not

 


Code:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Practical-14</title>
</head>

<body>
    <script>
        
        //Pallindrome

        var num = prompt("Enter the number");
        var str = 0,
            rem;
        var temp = num;
        while (num > 0) {
            rem = num % 10;
            num = parseInt(num / 10);
            str = str * 10 + rem;
        }

        if (temp == str) {
            alert("Your Number is Pallindrome");
        } else {
            alert("Your Number is not Pallindrome");
        }
    </script>
</body>

</html>

Output:





Comments

Popular posts from this blog

Write A Program To Print Hello World Using Lex

Apply inline, internal and external style sheet for the student registration form.