1
respuesta

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>
    let years = 2022;
  //2007
   document.write('Juan is:' + (years - 2007) + ' years old'); 
   document.write('<br>');
   document.write('<br>');
   document.write('Pedro is:' + (years - 2002) + ' years old');

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

   years = 2022;
   document.write('Jimena is:' + (years - 2010) + ' years old');
   document.write('<br>');
   document.write('<br>');
   document.write('Paola is:' + (years - 1995) + ' years old');
   document.write('<br>');
   document.write('<br>');
   document.write('Laura is:' + (years - 2005) + ' years old');
   document.write('<br>');
   document.write('<br>');

   let jimenaAge = 10;
   let paolaAge = 25;
   let lauraAge = 15;

   let name1 = 'Jimena',
    name2 = 'Paola',
    name3 = 'Laura';

    const average = Math.round((jimenaAge+paolaAge+lauraAge)/3);

    document.write(`The average age of ${name1}, ${name2} and ${name3} is ${average}`)

</script>

</html>
1 respuesta

Hola, Te comparto otra version, Sdos

<script>

function saltarLinea() {
    document.write("<br>");
    document.write("<br>");
}

function imprimir (frase) {
    document.write(frase);
    saltarLinea();
}

function calcularEdad(nombre, anhoNac) {

    var texto

    texto = "La edad de " + nombre + " es " + (anhoRef - anhoNac) + " años";

    imprimir(texto);
}


anhoRef = 2022;

    calcularEdad ("Juan", 1990);
    calcularEdad ("Pedro", 2000);
    calcularEdad ("Carlos", 2010);

</script>