I am trying to use Array.map to slice the description property of each object within an array.
docs = docs.map(function(currentValue, index, array){
currentValue['description'] = currentValue.description.slice(0,10);
return array;
});
When I console.log(docs) it appears as though it has worked. However, I can no longer access the properties for some reason.
console.log(docs[0].description); //undefined
It appears that I have turned my array of objects into an array of strings that appear to be objects. Any thoughts?
eachnotmap()as you are not doing any transformation of the items in the arraymapback intodocs, so it ended up being equivalent to aforEachloop (it just made the temp array and threw it away).