Guest User

Untitled

a guest
Nov 24th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. (function() {
  2.  
  3. let r_arr = [{q:1, a:true},{q:3, a:false}];
  4. let q_arr = [
  5. { q: 'one', o: [true, false] },
  6. { q: 'two', o: [true, false] },
  7. { q: 'three', o: [true, false] },
  8. { q: 'four', o: [true, false] }
  9. ];
  10.  
  11.  
  12. //final output: [{q:"one", a: true}, {q:"two", a: "N/A"}, {q:"three", a: false}, {q:"four", a:"N/A"}]
  13.  
  14.  
  15. let op = s_arr.filter((s, idx, arr) => {
  16. // console.log("s", s, idx, arr);
  17. let id = idx + 1;
  18. f_arr.map((f) => {
  19. if (id === f.q) {
  20. f.q = s.q;
  21. }
  22. else {
  23. // here it run the loops for the 12 times or more, based on s_arr
  24. }
  25. });
  26. });
  27.  
  28.  
  29.  
  30. console.log("f_arr", f_arr); // f_arr [ { q: 'one', a: true }, { q: 'three', a: false } ]
  31. console.log("s_arr", s_arr); // no changes
  32.  
  33. })();
Add Comment
Please, Sign In to add comment