-1
<html>
    <style>
 h2{
     font-size: 15pt
 }
div#Type{
margin-top: 20px
}
    
div#percs{
margin-top: 20px
} 
div#res{
margin-top: 20px
}
    </style>
<head>
    <body>
<h1>Calculando Consumo</h1>
<h2> Informe o tipo de carro (A, B e C). Informe o percurso rodado em km e calcule o consumo estimado, conforme o tipo, sendo (A=8, B=9 e C=12) km/litro</h2>
<div id='Type'>Tipo de Carro</div>
<input type="text"name="Carro"id="Carro" > 
<div id='percs'>Percurso em km</div>
<input type="number"name="Percurso"id="Percurso"> 
<input Type="button"name="calcular"id='Calcular'value='calcular' onclick="calcular()">
<div Id=res>Resultado</div>
        <script>
        
        //6) Informe o tipo de carro (A, B e C). Informe o percurso rodado em km e calcule o consumo
        //estimado, conforme o tipo, sendo (A=8, B=9 e C=12) km/litro
       calcular ()
       { 
        var carro = document.getElementsByName("Carro")
        var percurso = document.getElementsByName("Percurso")
        var perc = Number.parseInt(percurso.value)
        var consumo = document.getElementById('res');
        if(car == 'A'){
            consumo = perc / 8;
           consumo.innerHTML=('o seu carro consumiu ', consumo,' litros');
        }
            if(car == 'B'){
                consumo = perc / 9;
                consumo.innerHTML=('o seu carro consumiu ', consumo,' litros');
            }
            if(car == 'C'){
            consumo = perc / 12;
            consumo.innerHTML=('o seu carro consumiu ', consumo,' litros');
        }
    }
        </script>
    </body>
</head>
</html>
where the "calculate()" function is being called?
– Sérgio S. Filho
if(car == 'A'), who iscar? This variable does not seem to exist...– Woss
Because the
<body>is inside the<head>?– Vítor Ferragini
The function is being called with the command 'onclick no' input#calculate from the button
– Matheus Lima Fraga
the car variable was misspelled due to a modification I made in the code but even after changing it to car it still not running
– Matheus Lima Fraga
as for the body being inside the head was a mistake of mine that I have already fixed the error continues
– Matheus Lima Fraga
What happens is that when I click the calculate button it does not perform anything
– Matheus Lima Fraga
carrowill be an element of the DOM, concerning the<input>. If you need to compare his value you’ll need to docarro.value– Woss