Practical – 119.2 : Check Given Character is Vowel / Consonant
Program Code :
<!DOCTYPE html>
<html>
<head>
<title>Vowel Checker</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
}
input, button {
padding: 10px;
font-size: 16px;
}
</style>
</head>
<body>
<h2>Check If Character Is a Vowel</h2>
<input type=”text” id=”charInput” maxlength=”1″ placeholder=”Enter a letter”>
<button onclick=”checkVowel()”>Check</button>
<h3 id=”result”></h3>
<script>
function checkVowel() {
let char = document.getElementById(“charInput”).value.toLowerCase();
if (char.length !== 1 || !isNaN(char)) {
document.getElementById(“result”).innerText = “Please enter a single alphabet character.”;
return;
}
if (‘aeiou’.includes(char)) {
document.getElementById(“result”).innerText = `”${char}” is a vowel.`;
} else {
document.getElementById(“result”).innerText = `”${char}” is not a vowel.`;
}
}
</script>
</body>
</html>