Liliana797979

bitcoin - fundamentals

May 28th, 2021
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.      
  3. function data(input) {
  4.     let counterDays = 0;
  5.     let countBitcoins = 0;
  6.     let firstBitcoin = 0;
  7.     let sum = 0;
  8.     let counter = 0;
  9.  
  10.     for (let i = 0; i <= input.length - 1; i++) {
  11.         let amountGold = Number(input[i]);
  12.         let currentSum = amountGold * 67.51;
  13.         counterDays++;
  14.         if (counterDays % 3 === 0) {
  15.             currentSum *= 0.7;
  16.         }
  17.         sum += currentSum;
  18.         if (sum >= 11949.16) {
  19.             let j = 11949.16;
  20.             while (j <= sum) {
  21.                 countBitcoins++;
  22.                 if (countBitcoins === 1) {
  23.                     firstBitcoin += counterDays;
  24.                 }
  25.                 sum -= 11949.16;
  26.                 counter++;
  27.             }
  28.         }
  29.  
  30.     }
  31.     console.log(`Bought bitcoins: ${countBitcoins}`);
  32.     if (countBitcoins !== 0) {
  33.         console.log(`Day of the first purchased bitcoin: ${firstBitcoin}`);
  34.     }
  35.     console.log(`Left money: ${sum.toFixed(2)} lv.`);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment