Create a function called “numberInfo” which takes in three numbers as parameters/arguments. When the function is executed, it should output the following information to the console using...


Create a function called “numberInfo” which takes in three numbers as parameters/arguments. When the function is executed, it should output the following information to the console using console.log():


a. What numbers were used for the function


b. The sum of those numbers


c. The average of those numbers



Example of Function Call:


numberInfo(3, 5, 7);



Example Output:


“The numbers 3, 5, and 7 were provided. The total of these numbers is 15 and the average is 5.”


For this challenge, you’ll need to use the string concatenation operator in addition to the addition and division operators. You’ll need to create a function and then call the function after it’s created and provide it with 3 numbers as depicted above.


2. Create a function called “nameInfo” that takes in a user’s name as a parameter/argument. When that function is called, it should tell the user the following information about their name in either the console or through an alert:


a. What their name is


b. How many letters long it is


c. If it is a short, average, or long name



Example Function Call:


nameInfo(“Christopher”);



Example Output:


“Your name is Christopher. This name is 11 letters long and considered to be a long name.”


For the purposes of this challenge, names that are less than 5 letters are short, names that are 5-8 letters are average, and names with 9 or more letters are long. You’ll need an if/else if/else statement to handle these possibilities. The “.length” method for strings will help you get the length of the string. When creating your function, make sure it logs the information to the console. You can also have it output to the page if you’d like but the console will be easiest.


3. Use a prompt which asks for the age of the user. The user should be told their age, and depending on what number they provide, a different response should be generated. I’ve listed the age limits and the responses below. Some of the age ranges overlap in terms of definitions. Someone that is 65 is a senior citizen AND an adult. However, for the purposes of this assignment, we’ll consider them to be distinct.




0 years old – “Apparently, you don’t exist!”


1-17 years old – “You are a youngster.”


18-64 years old – “You are an adult.”


65-99 years old – “You are a senior citizen.”


100+ years old – “You are a centenarian.”




You will need to use a prompt, if/else if/else statements, and an alert or console.log(). You could also use a switch statement if you’d like. You’ll have to do research on the syntax for that though.
https://www.w3schools.com/jsref/met_win_prompt.asp
is a link that should help you with the prompt part.





Example Input/Output:


If I typed in 29, the output would be: “You are 29 years old and you are an adult.”


If I typed in 70, the output would be: “You are 70 years old and you are a senior citizen.”

Apr 27, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here