const data = [
{ name: "Nick", age: 14 },
{ name: "Jane", age: 20 },
{ name: "Joe", age: 18 },
{ name: "James", age: 22 },
{ name: "Marry", age: 15 }
];
function calcAvgAge(arr) {
"use strict";
return Math.round(arr.reduce((sum, current) => sum + current.age, 0) / arr.length);
}
console.log(calcAvgAge(data));
function calcAvgAge(arr) {
"use strict";
return Math.round(arr.reduce((sum, current) => sum + current.age, 0) / arr.length);
}
'use strict' Должен находиться в начале скрипта. а не внутри функции.