Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

295
Views
¿Por qué mi código no imprime el resultado final? Debería imprimirse debajo de un botón, sin embargo, no se imprime nada.

Es la primera vez que codifico con Javascript y no estoy seguro de cómo proceder para corregir este código. He intentado cosas básicas como comprobar que las variables se nombran correctamente. No estoy seguro de qué pasos tomar para corregir este código.

 <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Convert Fahrenheit to Centigrade</title> </head> <body> <h1>Convert Fahrenheit to Centigrade</h1> <p>Enter degrees in Fahrenheit</p> <input type="number" id="Fahrenheit"> <p>Degrees in Centigrade</p> <input type="number" id="Centigrade"> <br /><br /> <button onclick="doCalculation()">Calculate Centigrade from Fahrenheit</button> <p id="displayResult"></p> <script> var fahrenheit; //var centigrade; var convertedResult; function calculateTemperature(fahrenheit) { var temperature = (fahrenheit - "32") * 5 / 9; return temperature; } function doCalculation(){ fahrenheit = document.getElementById("Fahrenheit").value; //centigrade = document.getElementById("Centrigrade").value; convertedResult = calculateTemperature(fahrenheit) document.getElementById("displayResult").innerHTML+= fahrenheit + "in Centigrade is" + temperature; } </script> </body> </html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La temperature variable que está utilizando dentro del valor que se está imprimiendo no está definida. Si revisa el navegador, la consola, podrá identificar ese error.

El valor del resultado se almacena en la variable convertedResult . Esa variable debe usarse dentro del valor que se está imprimiendo en lugar de temperature

 function doCalculation(){ fahrenheit = document.getElementById("Fahrenheit").value; //centigrade = document.getElementById("Centrigrade").value; convertedResult = calculateTemperature(fahrenheit) document.getElementById("displayResult").innerHTML = fahrenheit + "in Centigrade is" + convertedResult; }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!