const data = JSON.parse(value);

var sum = 0,
	count = 0;

for (var key in data) {
	if (data.hasOwnProperty(key)) {
		sum += data[key].average;
		count++;
	}
}

if (count == 0) {
	return 0;
}

return sum / count;