PROMEDIO

 avatar
unknown
javascript
2 years ago
825 B
3
Indexable
    <form>
        <label>Nota 1: <input type="text" id="nota1"></label>
        <br>
        <label>Nota 2: <input type="text" id="nota2"></label>
        <br>
        <label>Nota 3: <input type="text" id="nota3"></label>
        <br>
        <button type="button" onclick="promedio()">Calcular promedio</button>
      </form>
      <br>
      <p id="resultado"></p>
      
      <script>
        function promedio() {
          let nota1 = parseFloat(document.getElementById("nota1").value);
          let nota2 = parseFloat(document.getElementById("nota2").value);
          let nota3 = parseFloat(document.getElementById("nota3").value);
      
          let promedio = (nota1 + nota2 + nota3) / 3;
      
          document.getElementById("resultado").innerHTML = "El promedio es: " + promedio;
        }
      </script>
Editor is loading...