0% found this document useful (0 votes)
2 views1 page

Program 3

The HTML5 file contains a JavaScript script that prompts the user for input and performs two functions based on the input type. If the input is a number, it reverses the digits and displays the result; if it's a string, it finds the position of the left-most vowel and alerts the user. The script handles both scenarios with appropriate alerts for each outcome.

Uploaded by

Manju Sk17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Program 3

The HTML5 file contains a JavaScript script that prompts the user for input and performs two functions based on the input type. If the input is a number, it reverses the digits and displays the result; if it's a string, it finds the position of the left-most vowel and alerts the user. The script handles both scenarios with appropriate alerts for each outcome.

Uploaded by

Manju Sk17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Develop and demonstrate a HTML5 file that includes JavaScript script that uses

functions for the following problems:

a. Parameter: A string
b. Output: The position in the string of the left-most vowel
c. Parameter: A number
d. Output: The number with its digits in the reverse order

<!DOCTYPE HTML>
<html>
<body>
<script type="text/javascript">
var str = prompt("Enter the Input","");
if(!(isNaN(str)))
{
var num,rev=0,remainder;
num = parseInt(str);
while(num!=0)
{
remainder = num%10;
num = parseInt(num/10);
rev = rev * 10 + remainder;
}
alert("Reverse of "+str+" is "+rev);
}
else
{
str = str.toUpperCase();
for(var i = 0; i < str.length; i++)
{
var chr = str.charAt(i);
if(chr == 'A' || chr == 'E' || chr == 'I' || chr == 'O' || chr == 'U')break;
}
if( i < str.length )
alert("The position of the left most vowel is "+(i+1));
else
alert("No vowel found in the entered string");
}
</script>
</body>
</html>

You might also like