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[0] with b[0], a[1] with b[1], and a[2] with b[2].

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[0] += 1
} else if (a[i] < b[i]) {
scoreBoard[1] += 1
}
i++
}
return scoreBoard
}
```

- I created a scoreBoard and set it equal to [0, 0], each element representing both Alice’s and Bob’s points initially.
- I created a counter and while loop that uses that counter.
- I created an if else if conditional.
- 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[0], otherwise if Bobs criteria score is greater than Alice’s then we increment Bob’s final score by 1.

## Discussion (2)

I would do something like this:

It used coercion in javascript so we do not need to use if-else here

FYI It passed all test cases!

sick lol