DEV Community

Discussion on: Hacker Rank: Compare the Triplets

Collapse
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!

Collapse
greedybrain profile image
Naya Willis Author

sick lol