Hi, I am trying to write a script that will return a number incrementing by 1%.
Similar to the question: If I have 1 dollar, and it gains 1% everyday, how long will it take to reach 1 million?
I have tried writing functions and loops, but the only way I can successfully do this is to tediously write out an extremely long script. I know there has to be a better way to do this.
Any hints?
let ragsRiches = (x) => {
let dayOne = x*1.01;
let dayTwo = dayOne*1.01;
let dayThree = dayTwo*1.01;
let dayFour = dayThree*1.01;
let dayFive = dayFour*1.01;
let daySix = dayFive*1.01;
let daySeven = daySix*1.01;
console.log("Starting Balance: " + x);
console.log("Day One Balance: " + dayOne);
console.log("Day Two Balance: " + dayTwo);
console.log("Day Three Balance: " + dayThree);
console.log("Day Four Balance: " + dayFour);
console.log("Day Five Balance: " + dayFive);
console.log("Day Six Balance: " + daySix);
console.log("Day Seven Balance: " + daySeven);
}