const result = depositProfit(deposit, rate, threshold)
// log
console.log("result: ", result);
// assert
expect(result).toBe(3);
});
});
let totalYears = 0
function depositProfit(deposit, rate, threshold) {
// write code here.
let incrementalProfit = deposit
if (incrementalProfit < threshold) {
incrementalProfit += rate/100 * incrementalProfit
totalYears++
depositProfit(incrementalProfit, rate, threshold)
}
return totalYears
}
/**
* Test Suite
*/
describe('depositProfit()', () => {
it('returns number of years it will take to hit threshold based off of deposit & rate', () => {
// arrange
const deposit = 100;
const rate = 20;
const threshold = 170;
// act