Skip to content

Commit ccb1e96

Browse files
committed
kata: money, money, money
1 parent 8f17d2e commit ccb1e96

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

money-money-money.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function calculateYears(principal, interest, tax, desired) {
2+
let count, profit;
3+
for (count = 0; principal < desired; count++) {
4+
profit = principal * interest * (1 - tax);
5+
principal += profit;
6+
}
7+
return count;
8+
}
9+
10+
console.log(calculateYears(1000, 0.05, 0.18, 1100), 3);
11+
console.log(calculateYears(1000, 0.01625, 0.18, 1200), 14);
12+
console.log(calculateYears(1000, 0.05, 0.18, 1000), 0);

0 commit comments

Comments
 (0)