Explore Westonci.ca, the top Q&A platform where your questions are answered by professionals and enthusiasts alike. Get immediate answers to your questions from a wide network of experienced professionals on our Q&A platform. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.

This task is an exercise in writing and testing JavaScript functions in the Chrome Console. You do not need to create an HTML web page for this part of the project.

Remember that the JavaScript prompt function returns a string regardless of what is entered by the user, which means any numbers entered will be strings. You will need to convert the strings to numbers using either parseInt (Links to an external site.) or parseFloat (Links to an external site.) function.

A. Write a function named avg3 that accepts three numbers and returns the average of the three numbers.

Example:

avg3 (4, 2, 6) = > 4

B. Write a function named getTip that accepts two numbers, the cost of a meal or other service, and the tip percentage, and returns a number representing the tip amount.

Example:

getTip (10.000, 0.15) => 1.5

When you have this function working, modify the getTip function to return a string representing the tip in a currency format. Hint: use the toFixed() (Links to an external site.) method.

Example:

getTip (10.00, 0.2) => $2.00

C. Write a function pizzaPSI that accepts two numbers, the cost of a pizza, and the diameter in inches, and returns the cost Per Square Inch (PSI) in currency format. You will need to calculate the area of the pizza to determine the cost per square inch (cost / area).

Example:

pizzaPSI (10.00, 12) => $0.09

pizzaPSI (23.95, 18) => $0.09

D. Write a function named isAlpha that accepts a character (i.e. a string of length one) and returns a true if it is a letter of the alphabet, and false if not a letter of the alphabet. The isAlpha function should accept both uppercase and lowercase characters.

Example:

isAlpha ("A") => true

isAlpha("!") => false

isAlpha(1) => false

E. Write a function named sumNumbers that accepts a single non-zero number (positive or negative), adds up all of the numbers between 0 and the number (inclusive), and returns the sum (positive or negative). If 0 is submitted to sumNumbers, 0 is returned.

You must use a while loop (or two) to calculate the sum.

Example:

sumNumbers (3) => 6

sumNumbers (-3) => -6

sumNumbers (0) => 0