document.addEventListener('DOMContentLoaded', function() { function fillTable(withPositionColumn, tableBodyElementName, numElements, playingIndex) { for (let i = 0; i < numElements; i++) { let trElem = ""; let positionColumn = ""; if (i == playingIndex) trElem += ``; else trElem += ``; if (withPositionColumn) positionColumn += `${i + 1}` let exampleTableEntry = ` \ ${trElem} \ ${positionColumn} \ T.E.E.D. \ Garden (Calibre Remix) \ undefined \ undefined \ 06:01 \ \ ` tableBodyElement = document.getElementById(tableBodyElementName); tableBodyElement.innerHTML += exampleTableEntry; } } fillTable(true, "queue-table-body", 8, 3); fillTable(false, "playlist-table-body", 15, -1); });