JSFiddle - React, Tailwind, and code Playground

by sjmcpherson

HTML

<table id="table33"></table>

CSS

table td{border:1px solid #ccc;}

JavaScript

var total=0;

var a = [2,3,5,6,2]


for (var i = 0; i < a.length; i++) {
    var table = document.getElementById("table33");
    var row = table.insertRow(0);

    var cell1 = row.insertCell(0);
    var cell2 = row.insertCell(1);


    cell1.innerHTML = a[i];
    cell2.innerHTML = a[i+1];


    total += a[i]

}

var footer = table.createTFoot();
var frow = footer.insertRow(0); 
var fcell1 = frow.insertCell(0);
var fcell2 = frow.insertCell(1);

fcell1.innerHTML = total;