steps in javascript 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

//want to link the form inputs with the submit 

// add event listner 

formEl.addEventListener("submit",click);

function click(event){
    event.preventDefault();
 var from = event.target.from.value;
 var to = event.target.to.value;
 var capacity = event.target.capacity.value;
 var reserve = event.target.reserve.value;
 var object=new data(from,to,capacity,reserve);
 object.leftedSeats();
 object.render();
 object.total();
 set();

}