Question

JavaScript When the button is pressed, the application should prompt the user to enter a string...

JavaScript
When the button is pressed, the application should prompt the user to enter a string or ‘***’ to quit, and then print output in the text area specifying how many vowels were in the string.
Vowels are the letters: a,e,i,o,u.
The application should then again do the above, until the user enters ‘***’. It should then alert
‘Thanks for using the vowel counter’ and exit.

Homework Answers

Answer #1
<!DOCTYPE html>
<script>
        function myFunction() {
          var str = prompt("enter a string or '***' to quit");
          while(true){
                if(str!='***'){
                        var c = str.match(/[aeiou]/gi).length;
                        document.getElementById("demo").innerHTML +=
                        "Count of vowels in "+str+" is: "+ c+"\n";
                        var str = prompt("enter a string or '***' to quit");
                }
                else
                {
                        alert('Thanks for using the vowel counter');
                        break;
                }
          }
        }
</script>
<html>
        <body>
                <button onclick="myFunction()">Press Button</button><br/><br/>
                <textarea id="demo" rows='10',cols='30'></textarea>
        </body>
</html>

In the above code loop will continue until user enters ***

finally the entire output is displayed in text area.

OUTPUT

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
JavaScript When the button is pressed, the application should prompt the user to enter a string...
JavaScript When the button is pressed, the application should prompt the user to enter a string or ‘***’ to quit, and then remove all instances of the following substring “erd” in the input string. Assume no spaces in the string. Make the entire string lowercase to start with. It should show the parsed string (with the words already removed) in the text area. The application should then again do the above, clearing out the text area before each iteration of...
Design and implement an application that reads a string from the user and then determines and...
Design and implement an application that reads a string from the user and then determines and prints how many of each vowel appear in the string. Have a separate counter for each vowel. Also, count and print the number of non-vowel characters. Note: The characters in the string must be considered as case-insensitive. i.e., You must consider both upper and lowercase letters as same. Example Output: Enter a string: hello Number of each vowel in the string: a: 0 e:...
Prompt the user to enter a string of their choosing. Store the text in a string....
Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (2 pt) Ex: Enter a sample text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue! You entered: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and,...
This is C. Please write it C. 1) Prompt the user to enter a string of...
This is C. Please write it C. 1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! You entered: we'll continue our quest in space. there will be...
For this assignment you'll be creating an application that has the user input a subtotal, tax...
For this assignment you'll be creating an application that has the user input a subtotal, tax rate and tip percentage and then displays the sales tax, tip amount and the total. You'll use JQuery instead of the getElementByX functions AND you will display all messages on the page (no alert or prompt boxes) The starter file is based off of the Lab 2 sales_tax application. Feel free to borrow code from your lab solution but realize you will need to...
Program Behavior Each time your program is run, it will prompt the user to enter the...
Program Behavior Each time your program is run, it will prompt the user to enter the name of an input file to analyze. It will then read and analyze the contents of the input file, then print the results. Here is a sample run of the program. User input is shown in red. Let's analyze some text! Enter file name: sample.txt Number of lines: 21 Number of words: 184 Number of long words: 49 Number of sentences: 14 Number of...
C++ Pig Latin Lab This assignment uses pointers to perform something done often in computer applications:...
C++ Pig Latin Lab This assignment uses pointers to perform something done often in computer applications: the parsing of text to find “words” (i.e., strings delineated by some delimiter). Write a program that encodes English language phrases into Pig Latin. Pig Latin is a form of coded language often used for amusement. Many variations exist in the methods used to form Pig Latin phrases. Use the following algorithm: to form a Pig Latin phrase from an English language phrase, tokenize...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
CSC 322 Systems Programming Fall 2019 Lab Assignment L1: Cipher-machine Due: Monday, September 23 1 Goal...
CSC 322 Systems Programming Fall 2019 Lab Assignment L1: Cipher-machine Due: Monday, September 23 1 Goal In the first lab, we will develop a system program (called cipher-machine) which can encrypt or decrypt a code using C language. It must be an errorless program, in which user repeatedly executes pre-defined commands and quits when he or she wants to exit. For C beginners, this project will be a good initiator to learn a new programming language. Students who already know...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...