tzi0

Untitled

Apr 16th, 2021
815
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const allowRegions = {
  2.   KrasKrai : 29,
  3.   Buryatia : 46,
  4.   Chuvashia : 21,
  5.   Moscow : 66,
  6. }
  7.  
  8. const response = {
  9.   _srv : true,
  10.   _www : false,
  11.   _color: "Yellow",
  12.   value: [
  13.   {
  14.   serialNumer : "99999",
  15.   mrId: "123123123",
  16.   deviceId: "123123123",
  17.   divisionId: "46",
  18.   },
  19.   {
  20.   serialNumer : "33333",
  21.   mrId: "32423523",
  22.   deviceId: "123521235",
  23.   divisionId: "21",
  24.   },
  25.   {
  26.   serialNumer : "89567547",
  27.   mrId: "3457685",
  28.   deviceId: "234379",
  29.   divisionId: "65",
  30.   },
  31.   ],
  32.   _power: 45,
  33.   _utc: false
  34.   }
  35.  
  36.  
  37. function getObjects(template, data) {
  38.   const regionNumbers = Object.values(template);  
  39.   return data.filter((device) => regionNumbers.includes(+device.divisionId));
  40. }
  41.  
  42. console.log(getObjects(allowRegions, response.value));
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×