Create the array object, then fill in individually so () are not an issue.
function packagenames() {
for ( i=0 ; i<pkgids.length ; i++ ){
input = "<td>" + pkgids[i] + "</td>";
output="<td>" + pkgnames[i] + "</td>";
document.body.innerHTML = document.body.innerHTML.replace(input,output);
}
}
<script>
var pkgids = new Array(<ComputedValue1>);<ComputedValue2>;
var pkgnames = new Array(<ComputedValue3>);<ComputedValue4>;
packagenames();
</script>