Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- let r_arr = [{q:1, a:true},{q:3, a:false}];
- let q_arr = [
- { q: 'one', o: [true, false] },
- { q: 'two', o: [true, false] },
- { q: 'three', o: [true, false] },
- { q: 'four', o: [true, false] }
- ];
- //final output: [{q:"one", a: true}, {q:"two", a: "N/A"}, {q:"three", a: false}, {q:"four", a:"N/A"}]
- let op = s_arr.filter((s, idx, arr) => {
- // console.log("s", s, idx, arr);
- let id = idx + 1;
- f_arr.map((f) => {
- if (id === f.q) {
- f.q = s.q;
- }
- else {
- // here it run the loops for the 12 times or more, based on s_arr
- }
- });
- });
- console.log("f_arr", f_arr); // f_arr [ { q: 'one', a: true }, { q: 'three', a: false } ]
- console.log("s_arr", s_arr); // no changes
- })();
Add Comment
Please, Sign In to add comment