Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Geo

a guest Mar 28th, 2020 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function geoCalc (geo){
  2.   var area = 0;
  3.   var count = 0;
  4.   var today = new Date();
  5.   for (let i = 0; i<geo.length; i++){
  6.     diff = Math.ceil((today-geo[i].createdAt) / (1000 * 60 * 60 * 24));
  7.     if (diff <= 30 && diff >=0){
  8.       if (geo[i].type=='triangulo'){
  9.         area += ((geo[i].dimensions.height*geo[i].dimensions.base)/2);
  10.         count ++;
  11.         continue;
  12.       }
  13.       if (geo[i].type=='quadrado' || geo[i].type=='retangulo'){
  14.         area += (geo[i].dimensions.height*geo[i].dimensions.base);
  15.         count ++;
  16.         continue;
  17.       }
  18.       if (geo[i].type=='circulo'){
  19.         area += (geo[i].dimensions.height*geo[i].dimensions.height*Math.PI);
  20.         count ++;
  21.         continue;
  22.       }
  23.       console.log ('Tipo Invalido');
  24.     }
  25.     }
  26.   return (area/count);
  27. }
  28.  
  29.  
  30.  
  31. console.log(geoCalc([{type:'triangulo',
  32.           dimensions:{height:12,
  33.                     base: 10,},
  34.           createdAt: new Date("2020-03-01")
  35.           },
  36.           {type:'circulo',
  37.           dimensions:{height:3,
  38.                     base: 10,},
  39.           createdAt: new Date("2020-03-01")
  40.           },
  41.           {type:'quadrado',
  42.           dimensions:{height:3,
  43.                     base: 10,},
  44.           createdAt: new Date("2020-03-01")
  45.           }
  46.           ,
  47.           {type:'jebedias',
  48.           dimensions:{height:3,
  49.                     base: 10,},
  50.           createdAt: new Date("2020-03-01")
  51.           }]));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top