Easy there, pal!
To access the Functions challenges in the JavaScript programming, you need to sign up and subscribe 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 interest rate for a deposit with simple interest,complexPercentis the 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 save the recommendations in two variables:
recommendedTypeis the recommended type of deposit. Assign'simple'string to this variable if you recommend a simple deposit and'compound'string if a deposit with a capitalization of interest is more profitable.finalAmountis the final deposit amount.
The task may seem complicated and time-consuming, but it is not the case, because you have already written half of the solution in the previous task. Your function for calculating interest 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 transfer into it values from input variables. 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 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.