Испытание: Деньги к деньгам

const calculateDeposit = function (initialDepositAmount, percentPerAnnum, timeOfDeposit, isWithCapitalization) {
  let totalSum = initialDepositAmount;
  const percentForMonth = percentPerAnnum * 0.01 / 12 * timeOfDeposit * totalSum;
  
  if (!isWithCapitalization) {
    totalSum = initialDepositAmount + percentForMonth; 
  }
  
  if (isWithCapitalization) {
    for (let i = 0; i < timeOfDeposit; i++) {
      totalSum = totalSum + (percentPerAnnum * 0.01 / 12) * totalSum; 
    }  
  }
  
  return Math.floor(totalSum);
};