Breaking the Records

  • + 0 comments

    Using javaScript: let max = scores[0]; let min = scores[0];

    let maxBreak = scores.reduce((result, curr) => {
        if(max < curr){
         result += 1; 
         max = curr; 
        }
        return result;
    }, 0); 
    
    let minBreak = scores.reduce((result, curr) => {
        if(min > curr){
         result += 1; 
         min = curr; 
        }
        return result;
    }, 0); 
    
    return [maxBreak, minBreak];
    

    }

    console.log(breakingRecords([12, 24, 10, 24]))