0% found this document useful (0 votes)
21 views3 pages

P4

Uploaded by

Vedant Sinha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views3 pages

P4

Uploaded by

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

Lab Program 4: Develop and demonstrate a HTML5 file that includes

JavaScript script that uses functions for the following problems:


a. Parameter: A string
Output: The position in the string of the left-most vowel
b. Parameter: A number
Output: The number with its digits in the reverse order.
Program 4a.html
<html>
<head><title>3A PROGRAM</title>
<SCRIPT>
function vow(st)
{
var pos;
pos=st.search(/[aeiouAEIOU]/);
if(pos<0)
alert("vowel not found\n");
else
alert("Position of the left most vowel is "+(pos+1));
}
</SCRIPT>
</head>
<body>
<FORM><p>Enter the text</p>
<input type="text" id="voweltext"/>
<input type="button" value="Click here"
onclick="vow(voweltext.value);"/>
</FORM></body>
</html>

Program 4b.html

<html>
<title>Reverse Number</title>
<script>
function rev()
{
var n=prompt("Enter Number"," ");
n=parseInt(n);
var temp=0,rev=0;
while(n>0)
{
temp=n%10;
rev=rev*10+temp;
n=n/10;
n=parseInt(n);
}
document.write("The Reverse number is:",rev);
}
</script>
<body>
<form>
<input type="button" value="Enter No" onclick="rev()";>
</form>
</body>
</html>

You might also like