daily pastebin goal
20%
SHARE
TWEET

Untitled

a guest Mar 21st, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. compare(rows_1, rows_2) {
  2.   rows_1.forEach(row_1 => {
  3.     rows_2.forEach(row_2 => {
  4.       row_1['checked'] = row_1.id === row_2.sub.id;
  5.     });
  6.   });
  7. }
  8.      
  9. rows_1 = [ {id: '1', title: '...'}, {id: '2', title: '...'}, ];
  10. rows_2 = [ {sub: {id: '1', title: '...'}}, {sub: {id: '2', title: '...'}} ];
  11.      
  12. [ { id: 9, title: '...', checked: false },
  13.   { id: 8, title: '...', checked: false },
  14.   { id: 7, title: '...', checked: false },
  15.   { id: 6, title: '...', checked: false },
  16.   { id: 5, title: '...', checked: false },
  17.   { id: 4, title: '...', checked: false },
  18.   { id: 3, title: '...', checked: false },
  19.   { id: 2, title: '...', checked: false },
  20.   { id: 1, title: '...', checked: true } ]
  21.      
  22. [ { id: 9, title: '...', checked: false },
  23.   { id: 8, title: '...', checked: false },
  24.   { id: 7, title: '...', checked: false },
  25.   { id: 6, title: '...', checked: false },
  26.   { id: 5, title: '...', checked: true },
  27.   { id: 4, title: '...', checked: true },
  28.   { id: 3, title: '...', checked: true },
  29.   { id: 2, title: '...', checked: true },
  30.   { id: 1, title: '...', checked: true } ]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top