function getPagesArr(pages, categories) { return pages.map(p=>{ var x = categories.find(c => c._id == p.ctgrId); x && (p.ctgrId = x.catClass); return p; }); }