DeveloperBreeze

Calculating Compound Interest in JavaScript

function calculateCompoundInterest(principal, rate, time) {
    const compoundInterest = principal * Math.pow(1 + rate / 100, time) - principal;
    return compoundInterest;
}
const principalAmount = 1000;
const interestRate = 5;
const timePeriod = 2;
const compoundInterest = calculateCompoundInterest(principalAmount, interestRate, timePeriod);
console.log('Compound Interest:', compoundInterest);

Related Posts

More content you might like

Code

How to Create a New MySQL User with Full Privileges

No preview available for this content.

May 01, 2025
Read More
Code
python

Configuring SQLAlchemy with PostgreSQL on Heroku: A Quick Guide

Without this replacement, SQLAlchemy might throw an error like:

ValueError: Could not parse rfc1738 URL from string 'postgres://...'

Nov 08, 2024
Read More
Code
php

How to Delete All WordPress Posts and Their Uploads Using a Custom PHP Script

No preview available for this content.

Oct 25, 2024
Read More
Code
php

How To enable all error debugging in PHP

<?php
// Turn on all error reporting
error_reporting(E_ALL);

// Display errors
ini_set('display_errors', 1);

// Optionally, you can log errors instead of displaying them
// ini_set('log_errors', 1);
// ini_set('error_log', '/path/to/php-error.log');

echo "Error reporting is enabled.";
?>
  • error_reporting(E_ALL);: Enables reporting for all levels of errors.
  • ini_set('display_errors', 1);: Ensures that errors are displayed in the browser.
  • If you prefer to log the errors instead of displaying them, you can uncomment the log_errors and error_log lines, specifying the path where errors should be logged.

Oct 25, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!