breakingRecords

    0

    0

    The code creates an array of length arrLength containing the maximum and minimum scores for the given set of scores. Then it iterates through the array, checking to see if the current score is greater than the max or less than the min. If so, it updates the max and min values.

    function breakingRecords(scores) {
      let max = 0,
        min = 0;
      let arrLength = scores.length;
      let maxScore = scores[0];
      let minScore = scores[0];
      for (let i = 1; i < arrLength; i++) {
        if (maxScore < scores[i]) {
          max++;
          maxScore = scores[i];
        } else if (minScore > scores[i]) {
          min++;
          minScore = scores[i];
        }
      }
      return(max,min)
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.