Calculate total waiting time and total turnaround time
for ( let i = 0 ; i < n ; i ++ ) { total_wt = total_wt + wt [ i ] ; total_tat = total_tat + tat [ i ] ; document . write ( " " + proc [ i ] . pid + " " + proc [ i ] . bt + " " + wt [ i ] + " " + tat [ i ] + " " ) ; } document . write ( " " + total_wt / n + " " ) ; document . write ( " " + total_tat / n + " " ) ; }