You are on page 1of 4

Pranav kumar mishra

209301481
Section F

Assignment 6
QUESTION 1 CODE:

<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>
</head>
<body>

<form action="">

<input type="text" name="" id="word">

<button onclick="vowel()">VOWEL</button>

</form>

<script>
function vowel() {

n = document.getElementById("word").value;

var j = n.length;

var x = 0;

for (var i = 0; i < j; i++) {

if (n.charAt(i) == 'a' || n.charAt(i) == 'e' || n.charAt(i) == 'i' || n.charAt(i)


== 'o' || n.charAt(i) == 'u') {

x = i;
break;

}
document.write("The string entered is:- " + n + "</br>The first vowel from
the left is:- " + n[x] + "</br>");
document.write("The location of the vowel is:- " + x);
}

</script>
</body>
</html>
QUESTION 2 CODE:

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>

<body>
<form>
<input type="text" id="number">
<button onclick="reverse()">Calculate</button>
</form>
<script>
function reverse() {
var x = document.getElementById("number").value;
var y = x.length;
document.write("The number entered is:- " + x + "</br>");
document.write("The number in reverse order is:- ");
for (var i = y - 1; i >= 0; i--) {
document.write(x[i]);
}

}
</script>
</body>

</html>

You might also like