1
respuesta

Mi código de la actividad

<!DOCTYPE html>
<html lang="en">
<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>HTML</title>
</head>
<body>

</body>
<script>

    // Saltos de linea.
    let lineJump = '<br><br><br>'

    // año actual 
    let years = 2022;
   document.write('Juan is:' + (years - 2007) + ' years old'); 
   document.write(lineJump);
   document.write('Pedro is:' + (years - 2002) + ' years old');

   years = 2025;
   document.write(lineJump);
   document.write('Carlos is:' + (years - 1997) + ' years old');
   document.write(lineJump);


   // FUNCTIONS

   function lineJump1() {
       document.write('<br>');
       document.write('<br>');
       document.write('<br>');
   }
   // ARROW FUNCTION
   //Una expresión de función flecha tiene una sintaxis más corta.
    print = sentence =>  document.write(`<big> + ${sentence} </big>`);

    lineJump1();

    print('Hello friends');

    lineJump1();
    // Este codigo calcula las edades de Juan, Pedro y Carlos.
    years = 2022;
   print('Juan is: ' (years - 2007) + ' years old'); 
   lineJump1();
   print('Pedro is: ' (years - 2002) + ' years old');
   lineJump1();
   years = 2025;
   print('Carlos is: ' (years - 1997) + ' years old');






    // Problema
    // Hallar la diferencia de edad de dos personas.

    lineJump1();
    function ageDiferent(sisterAge,myAge){
        // Resta de edades, para hallar la diferencia.
        let yearsDiferent = sisterAge - myAge;
        // Mostrar en pantalla.
        document.write(`Nuestra diferencia de edad es  ${yearsDiferent} años`);
       };
/* Recibe como primer parametro la edad de mi hermana y 
como sugundo parametro mi edad.
*/
ageDiferent(28,25)
</script>

</html>
1 respuesta

Hola Jorge, espero que estés muy bien.

Estamos muy contentos con tu aprendizaje. Excelente solución, he probado tu código y funciona muy bien, gracias por compartirlo con nosotros.

Continúa con tus estudios y cualquier duda estaremos aquí =)

Si este post te ayudó, por favor, marca como solucionado ✓. Continúa con tus estudios