Answer to Question #295891 in HTML/JavaScript Web Application for yash

Question #295891

WEB230 JavaScript 1 Assignment 3 - Quiz Average In this assignment we will write a JavaScript program to calculate the average of a set of quiz marks. Instructions 1. Create variable containing an array that will contain five or more numbers that represent the marks on quizzes. It is assumed that all quizzes will be out of 10 so the numbers must be values between 0-10. 2. Create a function that will take the array as an argument and return the average of the quizzes. 3. Output a text message with the values of the quizzes, space seperated without brackets. Use a template literal when constructing the output strings (AKA back-ticks, template literals are explained in the section on Strings in Chapter 1). 4. Output a text message with the final average rounded to one decimal place. Again use a teplate literal. 


1
Expert's answer
2022-02-10T00:19:10-0500
const numbers = [2, 7, 3, 8, 10, 6, 1]

function getAverageValue(arr) {
    let sum = 0;
    arr.forEach(num => {
        sum += num;
    });
    return sum / arr.length
}

console.log(getAverageValue(numbers))

console.log(`The values of the quizzes: ${numbers.join(' ')}`)
console.log(`Average rounded value: ${getAverageValue(numbers).toFixed(1)}`)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS