scrimba
Solution for day 1 of #javascriptmas
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

Solution for day 1 of #javascriptmas
AboutCommentsNotes
Solution for day 1 of #javascriptmas
Expand for more info
main.js
run
preview
console
function depositProfit(deposit, rate, threshold) {
// write code here.
let balance = deposit * ( 1 + rate / 100 );
let years = 1;

do {
balance = balance * ( 1 + rate / 100 );
++years;
} while( balance < threshold)

return years;

}



/**
* 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
172.79999999999998
,
"result: "
,
3
,
/index.html
LIVE