Find Average - exercise problem

Hi there, I have searched a bit trying to find something similar to this exercise problem, but did not find. Therefore, I signed up and here I am.
Here is the problem instructions:

You need to calculate the average of a collection of values. Every value will be valid number. The average must be printed with two digits after the decimal point.
On the first line, you will receive N - the number of the values you must read
On the next N lines you will receive numbers.
On the only line of output, print the average with two digits after the decimal point.
Example Input - 3 ___ 2.5, 1.25, 3 = Example Output 2.25

I don’t seem to succeed in connecting the input of 3 numbers and the three numbers itself. I have tried different cases but at best received 1 out of 5 correct. Here is the code itself.

let input = 3;
let numbers = [2.5, 1.25, 3];

let total = 0;

for (let i = 0; i < numbers.length; i++) {
    total += numbers[i];

console.log((total / input).toFixed(2));

Thanks for the help in advance.

there may be something wrong with how you are outputting the result, because I don’t see anything wrong

where does this challenge comes from?

It comes from Telerik Academy in Bulgaria. I think it changes the input with 4, 3 (where I pass), 3 (again), 5 and 2. I receive the following as a result.
2020-02-07 10.56.46 fdd282344d5e

do you know what are the inputs and the desired outputs for those test cases?

it seems weird they don’t ask for writing a function…

The other example input is 4 __ 1, 1, 1, 1 with output 1 (obviously). But what are the others I don’t know.
I assume that as a function it will look something like this:

let input = 4;
let numbers = [

//let inputGets = + gets();
function average(input) {
    let total = 0;
    for (let i = 0; i < numbers.length; i++) {
        total += numbers[i];

    return((total / input).toFixed(2));

I get the same result though…

try to create a variable result, and then console.log that variable

@ilenia in the software that I submit there is a little catch. You need to define the number with +gets(); and since I did not know how to define the array…all problems came from there. With this code, now everything is passed.

let input = [
let numbers = + gets();
let total = 0;
let arr = [];

    for (let i = 0; i < numbers; i++) {
        arr[i] = +gets();
    for (let i = 0; i < arr.length; i++) {
        total += arr[i];

console.log((total / arr.length).toFixed(2));

Thank you for the help. :wink: