Advertisement
0xCor3

Untitled

Jan 25th, 2022 (edited)
607
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // B: [
  2. //   B: ['B', 'O'],
  3. //   AB: {'A', 'B', 'AB'},
  4. // },
  5. // O: {'O'},
  6. // AB: {'A', 'B'},
  7. // AB: {'A', 'B', 'AB'}
  8.  
  9. function check(parentA, parentB, child) {
  10.   const list = {
  11.     A: {
  12.       A: ["A", "O"],
  13.       B: ["A", "B", "O", "AB"],
  14.       O: ["A", "O"],
  15.       AB: ["A", "B", "AB"],
  16.     },
  17.     B: {
  18.       B: ["B", "O"],
  19.       O: ["B", "O"],
  20.       AB: ["A", "B", "AB"],
  21.     },
  22.     O: {
  23.       O: ["O"],
  24.       AB: ["A", "B"],
  25.     },
  26.     AB: {
  27.       AB: ["A", "B", "AB"],
  28.     },
  29.   };
  30.   if (Object.keys(list).includes(parentA)) {
  31.     const prnt = list[parentA];
  32.     if (Object.keys(prnt).includes(parentB)) {
  33.       const getRest = prnt[parentB];
  34.       return getRest.includes(child) ? true : false;
  35.     } else {
  36.       return false;
  37.     }
  38.   } else {
  39.     return false;
  40.   }
  41. }
  42.  
  43. console.log(check("J", "O", "B"));
  44.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement