Question
Do the following in JAVASCRIPT language: Q1. Declare four variables and set them to floating-point values. Calculate the average of those variables and display it.
Do the following in JAVASCRIPT language:
Q1. Declare four variables and set them to floating-point values. Calculate the average of those variables and display it.
Q2. Write a function that takes two variables and returns the value of the larger one. Using that function and the four variables from Q1, display the value of the largest one.
Q3. Declare an array of five integer values. Using a loop, calculate and display their sum and average.
Q4. Write a function that takes an integer N and uses a loop to display all the positive integers up to N. Call that function with the value 8 to display "1 2 3 4 5 6 7 8". (note! do it on one line using string concatenation)
Q5. Using nested loops, and the variable from Q4, display that many rows of numbers. The first row should have 1, the second row should have 1 2, third row should have 1 2 3 and so on.
e.g. Input: 4
Display: 1
1 2
1 2 3
1 2 3 4
Q6. Using the array forEach method, display the numbers in the array from Q3.
Q7. Write a function that takes an array of numbers and returns the smallest value. Call that function with the array from Q3 and display the returned value.
Q8. Declare an associative array with three names as keys and ages as values. Display all the key/value pairs like: "Michael is 20".
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started