0xCor3

Getting the value with random key

Jan 22nd, 2022 (edited)
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const asu = [
  2.   {
  3.     casdi129389124: {
  4.       Products: {
  5.         AlienBoy040: {
  6.           name: "Alienboy040",
  7.           price: 12341412,
  8.         },
  9.         Garlek123: {
  10.           name: "asdadasdsad",
  11.           price: 12341412,
  12.         },
  13.       },
  14.       last_login: "9901823913",
  15.     },
  16.   },
  17.   {
  18.     asu012389123: {
  19.       Products: {
  20.         AlienBoy111: {
  21.           name: "Alienboy0123",
  22.           price: 12333333,
  23.         },
  24.       },
  25.       last_login: "99018123333",
  26.     },
  27.   },
  28. ];
  29.  
  30. const tampung = [];
  31.  
  32. asu.forEach((e) => {
  33.   let item = e[Object.keys(e)].Products;
  34.   for (const [key, value] of Object.entries(item)) {
  35.     tampung.push({ name: value.name, price: value.price });
  36.   }
  37. });
  38.  
  39. console.log(tampung);
  40.  
Add Comment
Please, Sign In to add comment