Good night guys.
There is a small question.
There is a function that cleans an array of objects.
I transfer the result of this function further along the chain .then and after the transfer the search of this object stops working.
What is the reason tell me who knows.
const remDupl = function (arr, fild) { var rez = {news:[]}; var lookupObject = {}; for(var i in arr) { lookupObject[arr[i][fild]] = arr[i]; } for( i in lookupObject) { rez.news.push(lookupObject[i]); } return rez; }; as you can see further, everything works well here.
const remDupl = function (arr, fild) { var rez = {news:[]}; var lookupObject = {}; for(var i in arr) { lookupObject[arr[i][fild]] = arr[i]; } for( i in lookupObject) { rez.news.push(lookupObject[i]); } return rez; }; let arr={ news : [ {'title': 'one'}, {'title': 'two'}, {'title': 'three'}, {'title': 'four', 'name': 'dima'}, {'title': 'four', 'name': 'alex'}, {'title': 'one', 'name': 'alex'}, ] }; let rec = remDupl(arr.news, 'title'); console.log(rec); However, the situation is worse when the result of this function is interrupted further through the promises.
Why is it added? Inex 0 and everything would be fine but even about this address by searching through forEach results --- tat Void
Here is the test of this function.
let rec = remDupl(arr.news, 'title'); console.log(rec); This is how the object looks after the transfer of promis
console.log(cleanArr); Apparently added index 0 from where? And why brute force does not work on it?
the conclusion of the previous promis.
.then(pulledNews => { return remDupl(pulledNews, 'title'); }) .then(cleanArr => { // console.log(cleanArr); cleanArr.news[0].forEach(item=>{console.log(item)}); }) 


