I'm generating HTML table using JavaScript objects, I created two functions with different headers:
function generateTable(data) {
let newobj = data.filter(function(el) {
return el.Sens == 'Depart';
})
.map(function(obj) {
return {
Heure: moment(obj.prevu).format("h:mm"),
Vol: obj.Numvol,
Compagnie: 'uploads/' + obj.FileName,
Destination: obj.AeroD + ' via ' + obj.AeroA,
Comptoir: obj.Comptoir.replace(/[\[\]']+/g, ''),
Porte: obj.porte,
Infos: obj.etat,
Enregistrement: obj.active_enregistrement,
}
});}
Second Function :
function generateArTable(data) {
let newobj = data.filter(function(el) {
return el.Sens == 'Depart';
})
.map(function(obj) {
return {
'التوقيت': moment(obj.prevu).format("h:mm"),
'الرحلة': obj.Numvol,
'الناقل الجوي': 'uploads/' + obj.FileName,
'الوجهة': obj.AeroD_ar + ' عبر ' + obj.AeroA_ar,
'الشباك': obj.Comptoir.replace(/[\[\]']+/g, ''),
'الباب': obj.porte,
'معلومات': obj.etat
}
});
they both generate an HTML table using the same table
let table = document.querySelector("#fr_table");
I want to a create function which has two parameters N and X:
- N is how many times to execute two functions
- X is interval between execution of the two functions
I have tried these functions:
setTimer0 = setInterval(function() {
generateArTable(data);
console.log("first function executed");
}, 3500, (0));
setTimer1 = setInterval(function() {
generateTable(data);
console.log("second function executed");
}, 3100, (1));
but it's not working as expected for the interval between the two functions.