step javascript code example
Example 1: javascript steps
function data(from, to, capacity, reserve,lefted) {
this.from=from;
this.to=to;
this.capacity=capacity ;
this.reserve=reserve ;
this.lefted=0;
this.leftedSum=0
}
data.prototype.render=function()
{
var tableEl = document.getElementById("table");
var trEl1=document.createElement('tr');
tableEl.appendChild(trEl1);
var tdEl1 = document.createElement('td');
trEl1.appendChild(tdEl1);
tdEl1.textContent=`${this.from}`
var tdEl2 = document.createElement('td');
trEl1.appendChild(tdEl2);
tdEl2.textContent=`${this.to}`
var tdEl3 = document.createElement('td');
trEl1.appendChild(tdEl3);
tdEl3.textContent=`${this.capacity}`
var tdEl4 = document.createElement('td');
trEl1.appendChild(tdEl4);
tdEl4.textContent=`${this.reserve}`
var tdEl5 = document.createElement('td');
trEl1.appendChild(tdEl5);
tdEl5.textContent=`${this.lefted}`
}
data.prototype.render();
Example 2: javascript steps
data.prototype.leftedSeats=function()
{
this.lefted = this.capacity-this.reserve ;
}
data.prototype.leftedSeats();