Understand the potential return on your investment with our easy-to-use ROI calculator. Return on Investment (ROI) is a performance measure used to evaluate the efficiency of an investment or compare the efficiency of a number of different investments. ROI tries to directly measure the amount of return on a particular investment, in relation to the investment's cost. To calculate ROI, the benefit (or return) of an investment is divided by the cost of the investment.
function calculateROI() {
var initialInvestment = parseFloat(document.getElementById("initialInvestment").value);
var currentValue = parseFloat(document.getElementById("currentValue").value);
var additionalInvestments = parseFloat(document.getElementById("additionalInvestments").value);
var withdrawals = parseFloat(document.getElementById("withdrawals").value);
var resultDiv = document.getElementById("result");
if (isNaN(initialInvestment) || initialInvestment <= 0) {
resultDiv.innerHTML = "Please enter a valid positive Initial Investment Cost.";
return;
}
if (isNaN(currentValue)) {
resultDiv.innerHTML = "Please enter a valid Current Value of Investment.";
return;
}
if (isNaN(additionalInvestments)) {
additionalInvestments = 0;
}
if (isNaN(withdrawals)) {
withdrawals = 0;
}
var netProfit = (currentValue – initialInvestment) – additionalInvestments + withdrawals;
var roiPercentage = (netProfit / initialInvestment) * 100;
resultDiv.innerHTML = "