Last active
January 19, 2021 23:38
-
-
Save Asatelit/864919b7f0f6c18e4b21ed029ec64d27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Solution for HackerRank > Algorithms > Warmup > Compare the Triplets | |
https://www.hackerrank.com/challenges/compare-the-triplets | |
*/ | |
(function solve(a0, a1, a2, b0, b1, b2) { | |
var aa = [a0, a1, a2]; | |
var bb = [b0, b1, b2]; | |
var a = 0; | |
var b = 0; | |
aa.forEach((element, index) => { | |
var ax = aa[index]; | |
var bx = bb[index]; | |
if (ax === bx) return; // neither person receives a point | |
return ax > bx ? a += 1 : b += 1; | |
}); | |
return [a, b]; | |
})(5, 6, 7, 3, 6, 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment