# Compare the Triplets | Printing two values.

 Subject: Compare the Triplets | Printing two values. Posted by: manish pamnani (manishpamnani1…@gmail.com) Date: Sun, 19 Jan 2020

Hey,

I am solving a problem on hackerrank(https://www.hackerrank.com/challenges/compare-the-triplets/problem?h_r=next-challenge&h_v=zen). The problem states to complete the function
compareTriplets which must return an array of two integers, the first being ALice's score and the secoond being Bob's.

compareTriplets has the following parameter(s):

a: an array of integers representing Alice's challenge rating
b: an array of integers representing Bob's challenge rating

For more detail on the problem, refer to the following link:
https://www.hackerrank.com/challenges/compare-the-triplets/problem?h_r=next-challenge&h_v=zen

For the same challenge i wrote the following solution:

```
function compareTriplets(a, b) {
for (let i = 0; i < 4; i ++) {
points=[];
pointsArray=[];
if (a[i] > b[i]) {
points[i]=1;
pointsArray.push(points[i])
}
if (a[i] === b[i]) {
points[i]=0;
}
if (b[i] > a[i]) {
points[i]=1;
pointsArray.push(points[i])
}
return pointsArray;
}
}
```

The problem states that the output should be like [1,1] i.e. [points earned by alice, points earned by bob]

But somehow it displays a array with four elements with the values [1], [], [1], []
Refer to https://ibb.co/GCkwM9j for further details.

Can anybody suggest anything?