I am currently utilizing _underscore library. My goal is to change the value of a specific key.
var users = [{
"_id": { "$oid":"3426" },
"name":"peeter"
}, {
"_id": { "$oid":"5a027" },
"name":"ken"
}, {
"_id": { "$oid":"5999" },
"name":"karmal"
}];
var index = _.find(users, function(o) { return o._id.$oid == '5999'; });
console.log(index);
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.js"></script>
In the output displayed in console.log(index)
, I aim to modify the value of the key (name) by appending "-Copy".
Desired result
{
"_id": {
"$oid": "5999"
},
"name": "karmal-Copy"
}
I only intend to add -Copy to the existing value of the key (name).