dynamic step registration js code example

Example 1: javascript steps

// want to creat a table 

//1- start with the header
var tableEl = document.getElementById("table");//Global variable we can use it without declare it again 
var headerArr=['from','to','capacity','reserve','lefted'];
function header(){
  var trEl = document.createElement('tr');
  tableEl.appendChild(trEl);
  for(var i=0 ; i < headerArr.length ; i++ ){
var thEl = document.createElement('th');
trEl.appendChild(thEl); 
thEl.textContent = `${headerArr[i]}`;
}
}
//call the function
header();

Example 2: javascript steps

//define the html form in JS
var formEl = document.getElementById("form");
var allData=[];