34.2k views
11 votes
Write an algorithm to find the average of three numbers: 10, 20, 30

User Hemaolle
by
3.5k points

1 Answer

10 votes

Language: JavaScript

Answer:

let num = [10,20,30];

average(num);

function average(num) {

let sum = 0;

for(let i in num) {

sum += num[i];

}

return console.log(sum/num.length);

}

User Kellyrose
by
4.2k points