Испытание:Вечный вопрос, программа работает, проверка не проходит, помогите)


#1

var initialAmount = 50000;
var duration = 12;
var simplePercent = 7;
var complexPercent = 6;

var calculateDeposit = function (initialAmount, duration, simplePercent, complexPercent) {
var total_amount_simple = 0;
var total_amount_complex = 0;
var recommendedType;
var finalAmount;

total_amount_simple = ((simplePercent / 1200) * duration * initialAmount) + initialAmount;

total_amount_complex = initialAmount;
  for (var i = 1; i <= duration; i++) {
    total_amount_complex += ((complexPercent / 1200) * total_amount_complex);
}

if (total_amount_simple > total_amount_complex) {
recommendedType = ‘simple’;
finalAmount = total_amount_simple;
} else {
recommendedType = ‘complex’;
finalAmount = total_amount_complex;
}

console.log(total_amount_simple);
console.log(total_amount_complex);
console.log(recommendedType);
console.log(finalAmount);
return recommendedType, Math.round(finalAmount);
}
calculateDeposit(10000, 9, 7, 6.8);

Где ошибка?


#2

Объявите переменные recommendedType и finalAmount перед функцией


#3

Работает, спасибо!


#4

Помогите, пожалуйста, разобраться, где ошибка?
var initialAmount = 50000;
var duration = 12;
var simplePercent = 7;
var complexPercent = 6;
var recommendedType=’’;
var finalAmount=0;

var calculateDeposit = function (deposit, percent, term, isCapitalized) {
percent = percent/12*0.01;

if (isCapitalized) {
for (var i=0; i<=term; i++){
deposit+ = deposit * percent;
}
}
else {
deposit+ = deposit * percent * term;
}
return Math.round(deposit);
}

var simpleDeposit = calculateDeposit (initialAmount, simplePercent, duration, false);
var complexDeposit = calculateDeposit (initialAmount, complexPercent, duration, true);

if (simpleDeposit < complexDeposit) {
recommendedType = ‘complex’;
finalAmount = complexDeposit;
console.log('Рекомендован ’ + recommendedType);
}
else {
recommendedType = ‘simple’;
finalAmount = simpleDeposit;
console.log('Рекомендован ’ + recommendedType);
}