Easy there, pal!
To access the Functions challenges in the JavaScript programming, you need to sign up first.
The program for calculating deposits showed two things:
That’s why choosing the most profitable type of deposit is not so easy. Fortunately, this task can be automated and deposits with different conditions can be compared. Anyway, here is a standard technical assignment:
Meow! I need a program to compare types of deposits. I specify deposit parameters in variables:
initialAmountis the initial deposit amount,depositDurationis the deposit term in months,simplePercentis the annual interest rate for a deposit with simple interest,complexPercentis the annual interest rate for a deposit with capitalization of interest.The program should calculate the final deposit amount for deposits with simple and capitalized interest, and then store the recommended deposit type and its final amount in two variables:
recommendedTypeis the recommended type of deposit. Assign the string'simple'to this variable if you recommend a simple deposit and the string'compound'if a deposit with capitalization of interest is more profitable.finalAmountis the final deposit amount.
The task may seem complicated and time-consuming, but it is not, because you have already written half of the solution in the previous task. Your function for calculating the final deposit amount has already been written and tested, which means that it works as it is supposed to. All we have left to do is copy it from the previous task, call it using the right arguments (for a deposit with simple interest and a deposit with capitalization), compare the results and determine which one is more profitable.
Long live code re-use!
This task can also be solved without using functions, because Muffin will keep changing the values of variables and testing your solution, just like he did in other chapters. But since you already have a tested and proven function, you can use it to speed up the solution. Then you will have to call this function yourself and pass the values from input variables to it as arguments. You already know how to do it.
When everything is ready, call the Boss, as always, by clicking the Hey boss, here’s your program! button.
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 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.