title: How can I make a function divide the total money by the total of names entered on the button?
body: <p>I only need a function so that I can divide #total by the total of names that were entered on the button. If you know the answer please help me, I'm a newbie in Javascript.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function ir() {
  
    const nombre = document.getElementById("nombre").value;
  
    let monto = document.getElementById("monto").value;
  
    const total = document.getElementById("total");
    const final = document.getElementById("final");
    const aporte = document.getElementById("aporte");
  
    const lineBreak = document.createElement("br");
    let newTotal = document.createTextNode(` ${nombre} : ${monto} `);
    total.appendChild(lineBreak);
    total.appendChild(newTotal);
  
    monto = Number(monto) + Number(final.innerHTML);
  
    final.innerHTML = `${monto}`;
    aporte.innerHTML = `${monto}`;
  };</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;h1&gt;Expenses app&lt;/h1&gt;
  &lt;p&gt;Enter how much each person spent&lt;/p&gt;
  &lt;p&gt;Nombre&lt;/p&gt;
  &lt;input type="text" id="nombre"&gt;
  &lt;br&gt;
  &lt;p&gt;Monto&lt;/p&gt;
  &lt;input type="number" id="monto"&gt;
  &lt;br&gt;
  &lt;button onclick="ir()"&gt;Enviar&lt;/button&gt;
  &lt;br&gt;
  &lt;p&gt;Total: &lt;span id="final"&gt;&lt;/span&gt; &lt;/p&gt;
  &lt;div id="total"&gt;
  &lt;/div&gt;
  &lt;p&gt;A cada uno le toca aportar: &lt;span id="aporte"&gt;&lt;/span&gt;&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>