See The Code

Function that calculates the Mortgage and updates the Page with results.

function calculateMortgage(value) {
let mortgage = saveMortgage(value);
let monthlyRate = getRate(mortgage.interest);
let initialLoan = parseInt(mortgage.principal);
let months = parseInt(mortgage.months);
let denominator = getPow(monthlyRate, months);
let monthlyPay = (initialLoan) * (monthlyRate / denominator);

const template = document.getElementById("Data-Template");
const resultsBody = document.getElementById("resultsBody");
resultsBody.innerHTML = "";

let totalInterest = 0;
let remainingLoan = initialLoan;

for (let i = 0; i < months; i++) { const dataRow=document.importNode(template.content, true); let
  monthlyInterest=remainingLoan * monthlyRate; 
  totalInterest +=monthlyInterest; 
  let monthlyPrincipal=monthlyPay -  monthlyInterest; 
  let monthlyPayment=monthlyPay + monthlyRate; 
  remainingLoan -= monthlyPrincipal; 
  let balance = remainingLoan; 
  dataRow.getElementById("interest").textContent=monthlyInterest;
 
  dataRow.getElementById("month").textContent=i + 1; dataRow.getElementById("payment").textContent=monthlyPayment;
  dataRow.getElementById("principal").textContent=monthlyPrincipal;
  dataRow.getElementById("totalInterest").textContent=totalInterest;
  dataRow.getElementById("balance").textContent=balance; resultsBody.appendChild(dataRow); 
}
  
  document.getElementById("resultPrincipal").textContent=initialLoan;
  document.getElementById("resultInterest").textContent=totalInterest;
  document.getElementById("resultCost").textContent=initialLoan + totalInterest;

}
        

Function that gets the interest for the Loan

function getRate(rate) {
let r = parseInt(rate) / 1200;
return r;
}
        

Function that gets the Monthly Payment including Interest

function getMonthlyPayment(rate, months) {
let m = (1 - Math.pow((1 + (rate)), -months));
return m;
}