step form 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

// now I want to calculate the lefted seats 

data.prototype.leftedSeats=function() //Acsses the constructor
{
    
    this.lefted = this.capacity-this.reserve ;

}

data.prototype.leftedSeats();