function generateTable() {    
    var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };  
    function addMonths(numOfMonths, date = new Date()) {
        date.setMonth(date.getMonth() + numOfMonths);

        return date.toLocaleDateString('es-ES', options);
      }
      const params = new URLSearchParams(document.location.search); 
      const interest = params.get("tic")*0.01/12;
      const pago = parseFloat(document.querySelector('#pago').value);
      const monto = parseFloat(document.querySelector('#monto').value);
      //const interestic = parseFloat(params.get("tic")/1200);  
      //const interestcv = parseFloat(params.get("tcv")/1200);
      const m = parseFloat(document.querySelector('#months').value);
      //const m = month-1
      localStorage.setItem( 'months', m );
      
   
      //let fechas = [currentDate]
      let periodos = [0]
      let fechas = [new Date().toLocaleDateString('es-ES', options)]
      let fecha = [new Date().toLocaleDateString('es-ES', options)]
      let saldo = [monto]
     
      let pagop = [- monto]
      let interes = [0]
      
      for (i = 0; i<m; i++){
      periodos[i+1] = periodos[i] + 1 ;
      fechas[i+1] = addMonths(i +1, new Date());

          }
      console.log(fechas)    
      for (i = 0; i<=m; i++){
      //capital_c[i+1] = (capital_c[i]*(1+interestic));
      saldo[i+1] = saldo[i]*(1+interest) + pago
      pagop[i+1] = -pago
      interes[i+1] = saldo[i]*interest
          }
      saldo[m] = saldo[m-1]*(1+interest)    
      pagop[m] = saldo[m]    
      //pagop[m] = saldo[m] 
      for (i = 0; i<=m; i++){ 
      saldo[i] = saldo[i].toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
      pagop[i] = pagop[i].toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
      interes[i] = interes[i].toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
      
      //fecha[i] = fechas[i].getUTCDay() + "/" + fechas[i].getUTCMonth()+1+"/"  + fechas[i].getUTCFullYear();
      fecha[i]= fechas[i];
          }
      var headers = ["Periodo", "Pago",
      "Ganancia", "Saldo", 
      "Fecha"];
      var table = document.createElement("TABLE");  //makes a table element for the page
          
      for(var i = 0; i <= m; i++) {
          var row = table.insertRow(i);                       
          row.insertCell(0).innerHTML = periodos[i];
          row.insertCell(1).innerHTML = pagop[i];
          row.insertCell(2).innerHTML = interes[i];
          row.insertCell(3).innerHTML = saldo[i];
          row.insertCell(4).innerHTML = fechas[i];
          
          
      }
  
      var header = table.createTHead();
      var headerRow = header.insertRow(0);
      for(var i = 0; i < headers.length; i++) {
          headerRow.insertCell(i).innerHTML = headers[i];
      }
  
      document.body.append(table);
      //var myData = [header.innerHTML, row.innerHTML]
      const myData = table
      console.log(myData.innerHTML)
      localStorage.setItem( 'saldoinsoluto', myData.innerHTML );
      //localStorage.setItem('table', document.getElementById('payment').innerHTML)

  }