Advertisement
alvinfnaldi

Compare The Triplets

Sep 24th, 2023
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2.   const compareTheTriplets = (a: number[], b: number[]) => {
  3.     let alicePoint= 0;
  4.     let bobPoint= 0;
  5.  
  6.     for (let i = 0; i < 3; i++) {
  7.       if (a[i] > b[i]) {
  8.         alicePoint++;
  9.       } else if (a[i] < b[i]) {
  10.         bobPoint++;
  11.       }
  12.     }
  13.  
  14.     const result = [alicePoint, bobPoint];
  15.     return result
  16.   };
  17.  
  18.   const a = [1, 2, 3];
  19.   const b = [3, 2, 1];
  20.   const result = compareTheTriplets(a, b);
  21.   console.log(result);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement