## DEV Community is a community of 620,905 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

# Hacker Rank: Compare the Triplets

Hacker Rank Challenge - Compare the Triplets

Problem:
Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty.

The task is to find their comparison points by comparing a with b, a with b, and a with b.
If a[i] > b[i], then Alice is awarded 1 point.
If a[i] < b[i], then Bob is awarded 1 point.
If a[i] = b[i], then neither person receives a point.

My Solution

``````function compareTriplets(a, b) {
const scoreBoard = [0, 0]
let i = 0
while (i < a.length) {
if (a[i] > b[i]) {
scoreBoard += 1
} else if (a[i] < b[i]) {
scoreBoard += 1
}
i++
}
return scoreBoard
}
``````
1. I created a scoreBoard and set it equal to [0, 0], each element representing both Alice’s and Bob’s points initially.
2. I created a counter and while loop that uses that counter.
3. I created an if else if conditional.
4. If a[i] Alice’s criteria score is greater than b[i] Bob’s criteria score, then we increment Alice’s final score by 1 which is scoreBoard, otherwise if Bobs criteria score is greater than Alice’s then we increment Bob’s final score by 1.

## Discussion (2) 