-
Notifications
You must be signed in to change notification settings - Fork 12
/
program4.html
28 lines (28 loc) · 929 Bytes
/
program4.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
<html>
<body>
<input type="text">
<button onclick="runScript()">Submit</button>
<p></p>
<script>
function runScript(){
var str = document.querySelector('input').value;
var num = parseInt(str);
if(num){
document.querySelector('p').textContent = '';
document.querySelector('p').insertAdjacentHTML('beforeend', num.toString().split('').reverse().join(''));
} else {
str = str.toLowerCase();
var arr = str.split('');
for(var i=0; i<arr.length; i++){
if(arr[i]=='a' || arr[i]=='e' || arr[i]=='i' || arr[i]=='o' || arr[i]=='u'){
i++;
document.querySelector('p').textContent = '';
document.querySelector('p').insertAdjacentHTML('beforeend', 'Input string is: ' +str+ ' Leftmost vowel: ' +arr[i-1]+ ' Position: ' +i);
break;
}
}
}
}
</script>
</body>
</html>