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

118
Views
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 answers
Answer question

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 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!