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

Create a Student registration form using following tags form,input,textarea,button,select,optio. The registration form must consist of following information: first name,Middle name,last name, gender(use radio button),address,phone no,email id,hobbies(use checkbox),city,state,country,collage name (use dropdown menu).