Experiment 2
Experiment 2
To accept string from user and reverse the given string and check whether it is
palindrome or not.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Palindrome Checker</title>
<script>
// Function to check if the string is a palindrome
function checkPalindrome() {
// Get the input string from the user
let inputString = document.getElementById("userInput").value;
// Check if the original string and reversed string are the same
if (cleanedString === reversedString) {
document.getElementById("result").innerText = "The string is a
palindrome!";
} else {
document.getElementById("result").innerText = "The string is not a
palindrome.";
}
}
</script>
</head>
<body>
<h2>Palindrome Checker</h2>
<p id="result"></p>
</body>
</html>
Output :-