How can I return the value of num from the whole idx() function.
Here's my code:
function idx(){
var table = document.getElementById("table-body"), rIndex;
var num;
for ( var i = 0; i <table.rows.length; i++){
var index = table.rows[i].onclick = function()
{
rIndex = this.rowIndex;
num = rIndex - 1;
console.log(num);
return num;
}
}
}