1234567891011121314151617 |
- <head></head>
- <body>
- <script>
- let temperStr = prompt("Enter please temperature with F or C ");
- temperVal = temperStr.substring(0, temperStr.length - 1);
- if (temperStr.charAt(temperStr.length - 1) == 'F') {
- let temperCels = (temperVal - 32.0) * 5.0 / 9.0;
- alert("Temperature in Celsius: " + temperCels.toFixed(1) + "C");
- }
- else {
- let temperFahr = (temperVal * 9.0 / 5.0) + 32.0;
- alert("Temperature in Fahrengeit: " + temperFahr.toFixed(1) + "F");
- }
- </script>
- </body>
|