Compare the Triplets

  • + 2 comments

    For Javascript, try not to overthink this. It's beginner so for loop, if...else if, comparisons, will do.

    function compareTriplets(a, b) {
        let scoreA = 0;
        let scoreB = 0;
        for (let i=0;i<3;i++) {
            if (a[i] > b[i]) {
                scoreA = scoreA + 1;
            } else if (a[i] < b[i]) {
                scoreB = scoreB + 1;
            }
        }
        return [scoreA, scoreB]
    }