- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Finding the date at which money deposited equals a specific amount in JavaScript
Problem
We have an amount of money amt > 0 and we deposit it with an interest rate of p percent divided by 360 per day on the 1st of January 2021. We want to have an amount total >= a0.
Our function should take these three parameters and return the date at which the amount will be equal to the desired amount
Example
Following is the code −
const principal = 100; const amount = 150; const interest = 2; const findDate = (principal, amount, interest) => { const startingDate = new Date('2021-01-01') const dailyInterestRate = interest / 36000 let startingMoney = principal let daysPassed = 0 while (startingMoney < amount) { daysPassed++ startingMoney += startingMoney * dailyInterestRate }; startingDate.setDate(startingDate.getDate() + daysPassed) return startingDate.toISOString().split('T')[0] }; console.log(findDate(principal, amount, interest));
Output
2040-12-26
- Related Articles
- In which of the following situations, does the list of numbers involved make an arithmetic progression and why?The amount of money in the account every year, when Rs. 10000 is deposited at compound interest at 8% per annum.
- Which HTML5 tags are more appropriate to represent money amount
- In which of the following situations, do the lists of numbers involved form an ( A P ) ? Give reasons for your answers.The amount of money in the account of Varun at the end of every year when Rs 1000 is deposited at simple interest of ( 10 % ) per annum.
- Arun received a gratuity of 18,60,750₹ on his retirement. He bought a car for 3,25,000₹. He invested 2,70,000₹ in mutual funds and deposited the remaining amount in fixed deposit in a bank. How much money he deposited in fixed deposit ?
- Finding word starting with specific letter in JavaScript
- Finding the k-prime numbers with a specific distance in a range in JavaScript
- Finding two prime numbers with a specific number gap in JavaScript
- Finding the nth day from today - JavaScript (JS Date)
- Finding least number of notes to sum an amount - JavaScript
- In-the-Money, At-the-Money, and Out-of-theMoney Options
- Finding life path number based on a date of birth in JavaScript
- Which equals operator (== vs ===) should be used in JavaScript?
- Finding content of arrays on the basis of specific property in JavaScript?
- Finding how many times a specific letter is appearing in a sentence in JavaScript
- Finding a specific row which has several ids separated by comma in MySQL?

Advertisements