Created
July 21, 2016 21:51
-
-
Save MariaSzubski/a5f596ff689d0b79f5f5f2e98a101ea8 to your computer and use it in GitHub Desktop.
Compare each value between two arrays. #hackerrank #warmup
This file contains hidden or 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 main() { | |
var A = [5,6,7]; | |
var B = [3,6,10]; | |
// Set counters to '0' | |
var alice = 0, bob = 0; | |
// Test each array and award a point to the array with the great value | |
for (var i = 0; i < A.length; i++){ | |
if (A[i] > B[i]){ | |
alice += 1; | |
} else if (A[i] < B[i]){ | |
bob += 1; | |
} | |
} | |
// Log the points for each array | |
console.log(alice + ' ' + bob); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment