1
respuesta

Edades

<!DOCTYPE html>
<html lang="es">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function saltarLinea() {
        document.write("<br>");
        document.write("<br>");
        document.write("<br>");
        document.write("<hr>");
        document.write("<br>");
        document.write("<br>");
      }

      function imprimir(frase) {
        document.write("<big>" + frase + "</big>");
        saltarLinea();
      }

      var anho = 2025;

      imprimir("Hola amigos");

      // este código calcula las edades de Juan, Pedro y Carlos
      imprimir("Juan tiene: " + (anho - 2000) + " años");
      imprimir("Pedro tiene: " + (anho - 1995) + " años");

      anho = 2030;
      imprimir("Carlos tiene: " + (anho - 2005) + " años");
    </script>
  </body>
</html>

1 respuesta

Gracias por compartirlo Saludos.-

Si el aporte te ayudó, marca como solucionado ✓ Y vamos continúa con tus estudios, y si tienes alguna pregunta, ¡no dudes en consultarme! 😊🤓