-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
60 lines (50 loc) · 2.47 KB
/
test.js
File metadata and controls
60 lines (50 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict';
let cMonth = document.querySelector('#month');
let cYear = document.querySelector('#year');
let bStart = document.querySelector('#bStart');
let addText = document.querySelector('#Otvet');
let one_years = +12, month = +0;
let dividend_income = +0;
let total_stock = +0;
let total_dividents = +0;
let add_every_month = +0;
let numbering = +0;
bStart.onclick = function () { // При нажатии на кнопку
let total = +document.querySelector('#inMonth').value;
let every_month = +document.querySelector('#inMonth').value;
let number_of_times = +document.querySelector('#numberYearMonth').value;
let percent = +document.querySelector('#percent').value;
let percent_years = +document.querySelector('#percent').value;
let stock_value = +document.querySelector('#stockPrice').value;
let dividents_value = +document.querySelector('#dividentsPrice').value;
if (cMonth.checked){
while (numbering < number_of_times)
{
add_every_month = (total / 100) * percent;
if (numbering >= 1)
{
total = total + every_month + add_every_month;
}else{
total = every_month + add_every_month;
}
numbering++;
if (numbering % 12 == 0) // Считает прибыль в конце года, и кол-во акций и дивидентов
{
total_stock = total / stock_value;
total_dividents = total_stock;
dividend_income = total_dividents * dividents_value;
total = total + dividend_income;
addText.innerHTML = addText.value + numbering + ": Банк: " + Math.round(total) +". Количество акций: " +Math.round(total_stock) +". Прибыль с дивидентов: "+ Math.round(dividend_income) + '\n';
// Выводит NaN в 12 строке, словно значение переменных парсит в string
console.log(typeof(total)) // Пытался понять ошибку
console.log(typeof(total_stock))
console.log(typeof(dividend_income))
console.log(typeof(addText + "2"))
}else{
addText.innerHTML = addText.value + numbering + ": Банк: " + Math.round(total) + "\n";
console.log(typeof(addText + "1"))
}
}
}
return false;
}