Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. results = [
  2. {id: 1, test: biology, candidates:[ {cid: 11},{cid: 12},{cid: 13}]},
  3. {id: 2, test: chemistry, candidates:[ {cid: 15},{cid: 16},{cid: 17}]},
  4. {id: 3, test: physics, candidates:[ {cid: 1},{cid: 6},{cid: 7}]}
  5. ];
  6.  
  7. var new_Result = results.map( function (subject) {
  8. let promises = [];
  9. if (subject.candidates && subject.candidates.length > 0)
  10. {
  11. subject.candidates.forEach( (element) => {
  12. promises.push(mobileUtil. getTotalMarksPerCandidate(element));
  13. });
  14. }
  15. return Promise.all(promises).then( result => {
  16. console.log('Check this out', result);
  17. subject.newCandidatelist = result;
  18. return subject;
  19. });
  20. });
  21. console.log('R: ', new_Result);
  22. resolve(params);
  23.  
  24. Thank you
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement