You are on page 1of 2

Web Designing and Internet Applications 1

Aim: - Develop and demonstrate a HTML 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

Tools: Notepad Editor and Web Browser like Internet Explorer, Google Chrome or Mozilla
Firefox.

 Standard Procedure for Creating and View a JavaScript document?


1. Use a text editor such as Notepad to write the document.
2. Save the file as filename.html on a PC. This is called the Document Source.
3. Open the file that you have saved in any browser Off-Line.
4. Your HTML page should now appear just like any other Web page in browser.
5. You may now switch back and forth between the Source and the HTML
Document
 switch to Notepad with the Document Source
 make changes .
 save the document again.
 switch back to browser .
 click on RELOAD and view the new HTML Document .
 switch to Notepad with the Document Source.

Coding:
<html>

<body>

<script type="text/javascript">

var str = prompt("Enter the Input",""); if(isNaN(str))

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;

}
Web Designing and Internet Applications 2

if( i < str.length )

alert("The position of the left most vowel is "+(i+1)); else

alert("No vowel found in the entered string");

else

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);
}

</script>

</body>

</html>

 Conclusions:

The JavaScript code has been executed successfully.

You might also like