<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<style>
*{background-color: rgba(25, 25, 18); color: aliceblue;}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EXAMPLE</title>
</head>
<h3>¿Alcohol o gasolina?</h3>
<script>
function impBr(cant){
for (let index = 0; index < cant; index++) {
document.write("<br>")
}
}
let litros = 40;
let distanciaGasolina = 480;
let distanciaAlcohol = 300;
const calcConsumo = (volumen, distancia)=>{
document.write(`Tanque: ${volumen} Litros`);
impBr(1);
document.write(`Distancia: ${distancia} Kilometros`);
impBr(2);
document.write((litros / distancia).toFixed(3) + " Litros consumidos por cada Km");
}
calcConsumo(litros, distanciaGasolina);
impBr(2);
calcConsumo(litros, distanciaAlcohol);
</script>
<body>
</body>
</html>