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 measures the amount of return on a particular investment relative to the investment's cost. To calculate ROI, the benefit (or return) of an investment is divided by the cost of the investment.
The formula for ROI is:
ROI = ((Final Value – Initial Investment) / Initial Investment) * 100%
A positive ROI indicates that the investment has generated a profit, while a negative ROI indicates a loss. This calculator helps you quickly determine the percentage gain or loss on your investments, providing a clear metric for evaluating their success.
function calculateROI() {
var initialInvestment = parseFloat(document.getElementById("initialInvestment").value);
var finalValue = parseFloat(document.getElementById("finalValue").value);
var resultDiv = document.getElementById("roiResult");
if (isNaN(initialInvestment) || isNaN(finalValue)) {
resultDiv.innerHTML = "Please enter valid numbers for both fields.";
return;
}
if (initialInvestment = 0) {
resultDiv.innerHTML = "ROI: " + roi.toFixed(2) + "% (Profit)";
} else {
resultDiv.innerHTML = "ROI: " + roi.toFixed(2) + "% (Loss)";
}
}