- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

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

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));

2040-12-26

- Related Questions & Answers
- Which HTML5 tags are more appropriate to represent money amount
- Which equals operator (== vs ===) should be used in JavaScript?
- What are the ways in which black money can be converted into white money?
- The Electricity-Free Air Conditioner Which Saves Money
- Finding least number of notes to sum an amount - JavaScript
- Finding a specific row which has several ids separated by comma in MySQL?
- Which equals operator (== vs ===) should be used in JavaScript comparisons
- Finding the k-prime numbers with a specific distance in a range in JavaScript
- Finding the nth day from today - JavaScript (JS Date)
- Finding word starting with specific letter in JavaScript
- Finding the maximum number using at most one swap in JavaScript
- Finding two prime numbers with a specific number gap in JavaScript
- Program to find total amount of money we have in bank in Python
- Finding smallest element in a sorted array which is rotated in JavaScript
- Finding the longest Substring with At Least n Repeating Characters in JavaScript

Advertisements