Easy there, pal!
To access the Functions challenges in the JavaScript programming, you need to sign up and subscribe first.
You’re ready to write one more program for the boss. He liked saving air miles and now he wants to save money for new lines of business. Naturally, went to a bank, found out about all the terms and conditions, and is now asking you to create a program for calculating the deposit. Here is the technical assignment:
Meow! I need to calculate how much money I will make on deposits with different terms and conditions. Design the program as
calculateDepositfunction with four parameters:
- Initial amount of the deposit;
- Interest per annum (number from 0 to 100);
- Term of deposit in months;
- With capitalization of interest or not (flag with a Boolean value).
The function must return the total amount of the deposit rounded to dollars using
Math.round(). Use any parameter names.If we have a simple deposit, the annual interest is divided by 12 and multiplied by the term of the deposit, and then the initial amount increases by the calculated interest.
Calculating a deposit with capitalization is more difficult: every month the annual interest accrued per month is added to the deposit amount (do not forget to divide the interest by 12), and the interest for the next month is calculated from the increased amount of the deposit.
If you are having trouble calculating interest on deposits, check out the hint.
Investing 1000 dollars at 8% per annum for 3 months.
If it’s a simple deposit, the total amount will be:
// Total interest
(0.08 / 12) * 3 * 1000 = 20 dollars
// Total deposit amount
1000 + 20 = 1020 dollarsIf it’s a deposit with capitalization, the total amount will be:
// Amount after the first month
1000 + (0.08 / 12) * 1000 = 1007 dollars
// Amount after the second month
1007 + (0.08 / 12) * 1007 = 1014 dollars
// Amount after the third month (final amount)
1014 + (0.08 / 12) * 1014 = 1021 dollarsWhen you are done, press Hey boss, here’s your program!, and Muffin will come by to test it. Just don’t call Muffin for silly little things! The boss can get mad!
You’ve gone to a different page
Click inside the mini-browser to shift the focus onto this window.
To access the Functions challenges in the JavaScript programming, you need to sign up and subscribe first.
Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.
Forgot to connect your email to the profile? Email us and we’ll help.