Advertisement
deddyprianto

COMPARE TRIPLETS ARRAY HACKERANK

Jan 2nd, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const data = [1, 2, 3];
  2.  
  3.   const alice = [1, 2, 3];
  4.   const bob = [3, 2, 1];
  5.   let scoreAlice = 0,
  6.     scoreBob = 0;
  7.   for (let i = 0; i < data.length; i++) {
  8.     alice[i] > bob[i] ? scoreAlice++ : alice[i] < bob[i] ? scoreBob++ : "";
  9.   }
  10.   console.log([scoreAlice, scoreBob]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement