home03_1.html 571 B

1234567891011121314151617
  1. <head></head>
  2. <body>
  3. <script>
  4. let temperStr = prompt("Enter please temperature with F or C ");
  5. temperVal = temperStr.substring(0, temperStr.length - 1);
  6. if (temperStr.charAt(temperStr.length - 1) == 'F') {
  7. let temperCels = (temperVal - 32.0) * 5.0 / 9.0;
  8. alert("Temperature in Celsius: " + temperCels.toFixed(1) + "C");
  9. }
  10. else {
  11. let temperFahr = (temperVal * 9.0 / 5.0) + 32.0;
  12. alert("Temperature in Fahrengeit: " + temperFahr.toFixed(1) + "F");
  13. }
  14. </script>
  15. </body>