function depositProfit(deposit, rate, threshold) {
// Isolated t in the compound interest equation
// I'm assuming this is compounded annually, so n = 1
// Plugged in the variables for A, P, and r
return Math.ceil((Math.log(threshold/deposit))/(Math.log(1+(rate/100))));
}
/**
* 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
const result = depositProfit(deposit, rate, threshold)
// log
console.log("result: ", result);
// assert
expect(result).toBe(3);
});
});