Create a simple Temperature calculator that will convert the temperature in Fahrenheit to Celcius Kelvin. Your calculator must include:
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
    <div class="wrapper">
        <div class="container">
            <input type="text" id="temp">
            <button type="button" onclick="calculateToCelsius()">Calculate</button>
            <div class="res"></div>
        </div>
    </div>
    <style>
        input {
            outline: none;
        }
        button {
            outline: none;
            border: 1px solid #252525;
            border-radius: 2px;
        }
        button:hover {
            background-color: #ccc;
            cursor: pointer;
        }
    </style>
    <script>
        function calculateToCelsius() {
            let temp = document.getElementById('temp').value;
            let res = document.querySelector('.res');
            let r = 0;
            r = Math.round((temp - 32) / 1.8);
            res.innerHTML = r + ' ℃';
        }
    </script>
</body>
</html>
Comments