Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $scope.getDeviceDataCost = function (device, count) {
  2.     var i, price, lastAffordable;
  3.     if (typeof count === 'undefined') {
  4.         count = $scope.buyMode;
  5.     }
  6.     lastAffordable = 0;
  7.     price = 0;
  8.     if (count === 0) {
  9.         i = 0;
  10.         while (price <= $scope.data) {
  11.             lastAffordable = price;
  12.             price += device.dataCostBase * Math.pow(device.dataCostIncrement - $scope.getDeviceCostReduction(device), device.count + i);
  13.             i += 1;
  14.         }
  15.         price = lastAffordable;
  16.     } else {
  17.         for (i = 0; i < count; i += 1) {
  18.             price += device.dataCostBase * Math.pow(device.dataCostIncrement - $scope.getDeviceCostReduction(device), device.count + i);
  19.         }
  20.     }
  21.     return Math.round(price * 100) / 100;
  22. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement