I'm iterating this JSON using a for loop:var movieObj = {    cat: {        moveName: Breath,        rating: [4, 5, 4, 3]    },    cat1: {        moveName: shallow,        rating: [5, 5, 5, 5, 4]    }}Is there any way to improve this code?var sum;Array.prototype.getSum = function (ele) {    sum = ele.reduce(function (a, b) {        return a + b    });    return sum / ele.length}for (var key in movieObj) {    var b = movieObj[key];    if (Array.prototype.getSum(b['rating']) < 5) {        console.log(b['moveName']);    }}
Get average of each nested array in dynamic object
javascript;json