javascript - Replace _.forEach with something else -


i have problem. i've made long function has 4 _.foreach in it. want replace of _.foreach else lodash or else.

so, have many arrays of object , want iterate on both of them , compare values both of them. i've made it, want better solution have cleaner code.

here function:

function refreshfruits() {      _.foreach($scope.fruits, function(fruit, index){         _.foreach(vm.toupdate.somethinglikefruits, function(somethinglikeafruit, dindex) {              .foreach(somethinglikeafruit.p, function(dep, nindex) {                      _.foreach(fruit.l, function(leg, legindex) {                                 if(leg.name === dep.legname) {                                     leg.disc = dep.discl;                                     leg.fore = dep.projection;                                 }                  });            });        });   });   } 

where fruits array of objects, vm.toupdate.somethinglikefruits array of objects , p , l arrays.

split refreshfruits() function more functions.

like:

function refreshfruite(){ }  function updatefruit(fruit){ }  function updatefruitvalue(fruit, index){ } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -