Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1: Write the JavaScript to prompt the user to enter a phrase. Then, using a loop, turn the phrase into an acronym (strictly speaking

image text in transcribedimage text in transcribed

Part 1: Write the JavaScript to prompt the user to enter a phrase. Then, using a loop, turn the phrase into an acronym (strictly speaking an initialism) by building a new string that contains the first letter of each word from the user entered phrase. Every letter in the resulting string should be capitalized. Output a message such as the following to the webpage. "Hello world" becomes HW It would look like this on the webpage Make Acronym "Hello World" becomes HW Run To insert the quotation marks, use either " inside a string or surround the string with single quotations marks as seen in the pre-assignment video. o The backslash is used to indicate a special character. 4*" + text + "*" would add quotation marks around the value in the variable text. "Vancouver" becomes V "Three letter acronym" becomes TLA "The quick brown fox jumped over the lazy dog" becomes TQBFJOTLD b) Basically, the acronym should include the first letter and any letter that has a space before it. You can assume the user will enter a phrase that only contains spaces and letters. Don't worry about any other characters. However, your code should be able to handle extra spaces. The acronym should only contain letters. If the user enters nothing or only enters spaces, output the message "No phrase was entered". Hello world" becomes HW "Hello world" becomes HW IMPORTANT: You must use a loop to check every character of the input and build the acronym. You will not receive credit if your solution does not do so. HINTS: input.charAt(4) === "" will tell you if the character at index 4 is a space. The trim() function will remove spaces from the beginning and end of the user's input for you. Part 2: Write the JavaScript to prompt the user to enter a positive even number. Use a while loop to ensure that the user gives a good value. Then you need to print to a
 element a diamond with the width and height set by the user. The cross will be made of slashes and backslashes. Do not use JavaScripts repeat function, the function from the lab or similar functions to repeat strings. They are a good solution, but produce the diamond using nested for loops with no helper functions.  To add a backslash add "\\" Since the backslash is used to signal a special character, you need to use a double backslash to add a single backslash to a string Ex. If the user enters the number 8 you need to show the following cross on the webpage:  The first row has 4 slashes and 4 backslashes  The second row has 3 slashes, 2 spaces, and 3 backslashes The third row has 2 slashes, 4 spaces, and 2 backslashes / WVII/ Whereas if the user had entered 4 you would have this cross: W/  Part 1: Write the JavaScript to prompt the user to enter a phrase. Then, using a loop, turn the phrase into an acronym (strictly speaking an initialism) by building a new string that contains the first letter of each word from the user entered phrase. Every letter in the resulting string should be capitalized. Output a message such as the following to the webpage. "Hello world" becomes HW  It would look like this on the webpage Make Acronym "Hello World" becomes HW Run To insert the quotation marks, use either " inside a string or surround the string with single quotations marks as seen in the pre-assignment video. o The backslash is used to indicate a special character. 4*" + text + "*" would add quotation marks around the value in the variable text. "Vancouver" becomes V "Three letter acronym" becomes TLA "The quick brown fox jumped over the lazy dog" becomes TQBFJOTLD b) Basically, the acronym should include the first letter and any letter that has a space before it. You can assume the user will enter a phrase that only contains spaces and letters. Don't worry about any other characters. However, your code should be able to handle extra spaces. The acronym should only contain letters. If the user enters nothing or only enters spaces, output the message "No phrase was entered". Hello world" becomes HW "Hello world" becomes HW IMPORTANT: You must use a loop to check every character of the input and build the acronym. You will not receive credit if your solution does not do so. HINTS: input.charAt(4) === "" will tell you if the character at index 4 is a space. The trim() function will remove spaces from the beginning and end of the user's input for you. Part 2: Write the JavaScript to prompt the user to enter a positive even number. Use a while loop to ensure that the user gives a good value. Then you need to print to a 
 element a diamond with the width and height set by the user. The cross will be made of slashes and backslashes. Do not use JavaScripts repeat function, the function from the lab or similar functions to repeat strings. They are a good solution, but produce the diamond using nested for loops with no helper functions.  To add a backslash add "\\" Since the backslash is used to signal a special character, you need to use a double backslash to add a single backslash to a string Ex. If the user enters the number 8 you need to show the following cross on the webpage:  The first row has 4 slashes and 4 backslashes  The second row has 3 slashes, 2 spaces, and 3 backslashes The third row has 2 slashes, 4 spaces, and 2 backslashes / WVII/ Whereas if the user had entered 4 you would have this cross: W/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

Knowledge of process documentation (process flow charting)

Answered: 1 week ago