4. VTU WEB TECHNOLOGY LAB | READ NOW
VTU WEB TECHNOLOGY LAB
4] DEVELOP AND DEMONSTRATE A HTML5 FILE THAT INCLUDES JAVASCRIPT SCRIPT THAT USES FUNCTIONS FOR THE FOLLOWING PROBLEMS
- PARAMETER: A STRING
- OUTPUT: THE POSITION IN THE STRING OF THE LEFT-MOST VOWEL
- PARAMETER: A NUMBER
- OUTPUT: THE NUMBER WITH ITS DIGITS IN THE REVERSE ORDER
STEPS TO EXECUTE HTML PROGRAM
- Copy the html code given below
- Save it with .html file name extension
- Click double click on your saved html file
- Exection successfull
Solution 1 – [prog4.html]
<script> var a = prompt("Enter The Query"),b = parseInt(a),z=0; if(b) { while(b>0) var r= b%10, z= z*10+r, b = Math.floor(b/10); document.write("Entered Query : "+ a +"<br> Given Number In Reverse Order : "+ z); } else { a = a.search(/[aeiouAEIOU]/); document.write("The First Occurence Of Vowel is at : "+ (a+1)); } </script>
WEB TECHNOLOGY Output
WEB TECHNOLOGY Solution 2 – [ prog4.html]
<!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>