-
-
Save mitesh9991/775e2fb172bd232919615e2209fe0a8e 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