I am writing a code to count the number of times a time duration in column B is repeated.After writing a code according to my logic I am still getting error or no output. Here's the app script code I have written. Help me out.
function count() {
    var data = SpreadsheetApp.getActive();
    var sheet = data.getSheetByName("Sheet4");
    var lastRow = sheet.getLastRow();
    var sh = sheet.getRange('B1:B' + lastRow);
    var cell = sh.getValues();
    var count = 0;
    for (var i = 0; i < lastRow; j++) {
        var column2 = cell[i][1];
        for (var j = 0; j < i; j++) {
            var column4 = cell[j][1];
            if (column4 == column2) {
                count++;
            }
        }
        sheet.getRange('F' + (i + 1).toString()).setValue(count);
    }
}
This is the intended output instead of column F i put the sample output in column C 


 
     
     
    