Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

121
Vistas
document.write not printing

When I enter the inputs, it only outputs the value of Celsius but not Fahrenheit. I want my input to have 1 decimal place. Why is that and how do I fix it?

<script>
            
            let fahrenheit = prompt("Input a Fahrenheit temperature:");
            
            let celsius = (fahrenheit - 32) * 5 / 9;
            
        </script>
        <p>
            <script>document.write("Fahrenheit: " + fahrenheit.toFixed(1));</script>   
        </p>
        <p>
            <script>
                document.write("Celsius: " + celsius.toFixed(1));
            </script>  
        </p>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

toFixed() is a method of Number. You first need to convert your string to a float

<script>
            
            let fahrenheit = prompt("Input a Fahrenheit temperature:");
            
            let celsius = (fahrenheit - 32) * 5 / 9;
            
        </script>
        <p>
            <script>document.write("Fahrenheit: " + parseFloat(fahrenheit).toFixed(1));</script>   
        </p>
        <p>
            <script>
                document.write("Celsius: " + parseFloat(celsius).toFixed(1));
            </script>  
        </p>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda