Skip to content

Instantly share code, notes, and snippets.

@soiqualang
Created April 12, 2024 08:43
Show Gist options
  • Save soiqualang/b21701672f187f852fb89366ac753acd to your computer and use it in GitHub Desktop.
Save soiqualang/b21701672f187f852fb89366ac753acd to your computer and use it in GitHub Desktop.
So sanh va ghep mang
var doman_v1 = [
['recid', 'Year', 'Income', 'Type', 'Time'],
[42, '2011-05-01', '', 'doman', 1304182800000],
[41, '2012-01-01', '26', 'doman', 1325350800000],
[40, '2012-02-01', '234', 'doman', 1328029200000],
[39, '2012-03-01', '12', 'doman', 1330534800000],
[36, '2013-01-01', '', 'doman', 1356973200000],
[35, '2013-02-01', '267', 'doman', 1359651600000],
];
var data_tong = [
['Year'],
['2011-02-01'],
['2011-02-01'],
['2011-03-01'],
['2011-04-01'],
['2011-05-01'],
['2012-01-01'],
['2012-02-01'],
['2012-03-01'],
['2012-04-01'],
['2012-05-01'],
['2013-01-01'],
['2013-02-01'],
];
data_tong.shift();
for(var i=0;i<data_tong.length;i++){
// console.log(data_tong[i][0]);
/* for(var j=0;j<doman_v1.length;j++){
//console.log(doman_v1[j][1]);
if(data_tong[i][0] != doman_v1[j][1]){
doman_v1.push([42, data_tong[i][0], '', 'doman', data_tong[i][0]]);
//console.log(data_tong[i][0]);
}
} */
if(!doman_v1.includes(data_tong[i][0])){
// id minh se viet ham tao sau, gio mac dinh la 42
doman_v1.push([42, data_tong[i][0], '', 'doman', Date.parse(data_tong[i][0])]);
}
}
@soiqualang
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment