scrimba
Note at 0:14
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 0:14
AboutCommentsNotes
Note at 0:14
Expand for more info
main.js
run
preview
console
function depositProfit(deposit, rate, threshold) {
// write code here.
var A = deposit;
var F = rate;
var year = 0;

while(threshold >= A){
A += (A*F)/100;
year++;
}

return year;
}



/**
* 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);
});
});
Console
"result: "
,
3
,
/index.html
LIVE