DEV Community

Discussion on: Hacker Rank: Compare the Triplets

bugb profile image
bugb • Edited on

I would do something like this:

const compareTriplets=(a,b)=>a.reduce((m,n,i)=>[m[0]+(n>b[i]),m[1]+(b[i]>n)],[0,0])
Enter fullscreen mode Exit fullscreen mode

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

FYI It passed all test cases!

greedybrain profile image
Naya Willis Author

sick lol