How to find and replace in an array in underscore js

    To find and replace in an array using underscore js find function. There are many different ways but i use this approach because it find stops traversing the list when it finds the element
     
    var newArray = [{name: "mohit", age: 5},{name: "amar", age:15},{name: "raj", age: 50},{name: "chop", age: 25},{name: "nini", age: 45}];
        _.find(newArray, function(item, index) {
           if (item["name"]  == "mohit") {
               newArray[index] = {name: "chopper", age: 58};
               return true;
           } else {
               return false;
           }
        });
    5
    Average: 5 (1 vote)