Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict'
- var data1 = [
- ['A1', 'B1', 'C1', 'Key-A001', 'Key-A002', 'Key-A005', '', ''],
- ['A2', 'B2', 'C2', 'Key-A001', 'Key-A004', '', '', ''],
- ['xx', 'yy', 'zz', 'Key-B002', 'Key-A004', 'Key-X999', 'Key-A002', '']
- ]
- var data2 = [
- ['val_a1', 'I am valueA1', 'A001'],
- ['val_a2', 'I am valueA2', 'A002'],
- ['val_a3', 'I am valueA3', 'A003'],
- ['val_a4', 'I am valueA4', 'A004'],
- ['val_a5', 'I am valueA5', 'A005'],
- ['val_B_one', 'I am valueB1', 'B001'],
- ['val_B_two', 'I am valueB2', 'B002']
- ]
- var data3 = data1.map(e => {
- return e.map((e1, i) => {
- var key = e1.match(/\w\d+$/)
- var found
- if (key) {
- found = data2.find(e2 => e2[2] === key[0])
- }
- if (i < 3 || !key || !found) {
- return e1
- }
- return `${found[0]}<br>(${found[2]})`
- })
- })
- console.log(data3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement