-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathprog4.html
54 lines (53 loc) · 1.54 KB
/
prog4.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<html>
<head>
<title>Program 4</title>
<style>
div{
background-color: white;
width: 60%;
height:20%;
padding: 5px;
border: 2px solid black;
}
</style>
</head>
<body style="background-color:#434444">
<main style="max-width: 500px; margin: auto;">
<center>
<input type="text" id="str" placeholder="Enter String/Number">
<input type="submit" onclick="eval();" value="submit" name="sub">
<h2 ><font color="white">RESULT</font></h2>
<div id="result"></div>
<script>
function eval() {
var str = document.getElementById("str").value;
if (Number.isInteger(parseInt(str))) {
var num = parseInt(str);
var rev = 0, rem = 0;
while (num > 0) {
rem = parseInt(num % 10);
rev = rev * 10 + rem;
num = parseInt(num / 10);
}
result.innerHTML = "<p>Reverse of <strong> " + str + " is " + rev +"</strong></p>";
}
else {
var text = "<p>The Entered string is: <strong>" + str + "</strong></p>";
for (var i = 0; i < str.length; i++)
{
if (str.charAt(i) == 'a' || str.charAt(i) == 'e' || str.charAt(i) == 'i' || str.charAt(i) == 'o' || str.charAt(i) == 'u' || str.charAt(i) == 'A' || str.charAt(i) == 'E' || str.charAt(i) == 'I' || str.charAt(i) == 'O' || str.charAt(i) == 'U')
{
text += "<p>The Leftmost Vowel <strong>" + str.charAt(i) + "</strong> is at pos <strong>"+ (i+1) + "</strong></p>";
result.innerHTML = text;
exit;
}
}
text += "<p> The Entered String Has No Vowels</p>";
result.innerHTML = text;
}
}
</script>
</center>
</main>
</body>
</html>