हिंदी

Write event driven JavaScript program for the following. Accept any string from user and count and display number of vowels occurs in it.

Advertisements

प्रश्न

Write event driven JavaScript program for the following.

Accept any string from user and count and display number of vowels occurs in it.

संक्षेप में उत्तर
Advertisements

उत्तर

Coding:

<html>
<script type="text/javascript">
    var n, i, ch, cnt = 0;
    n = prompt("Enter a String");
    for (i = 0; i < n.length; i++) {
      ch = n.charAt(i);
      if (ch == 'a' || ch == ' A' || ch == 'e' || ch == 'E' || ch == 'i' ||
      ch == 'I' || ch == 'o' || ch == 'O' || ch == 'u' || ch == 'U') {
        cnt = cnt + 1;
      }
    }
    document.write("Number of vowels in string are " + cnt);
</script>
</html>
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 3: Advanced Javascript - Exercises [पृष्ठ ५१]

APPEARS IN

बालभारती Information Technology (Science) [English] Standard 12 Maharashtra State Board
अध्याय 3 Advanced Javascript
Exercises | Q 7.4 | पृष्ठ ५१
Advertisements
Share
Notifications



      Forgot password?
Use app×