How can I access the values of two input fields in order to perform calculations as soon as their values are updated?
<script>
// Accessing the values of the two input fields for immediate calculation based on user input
const heightInputEl = document.querySelector('.height-input');
const weightInputEl = document.querySelector('.weight-input');
heightInputEl.addEventListener('input', function (e) {
const height = Number(e.target.value);
const mtrsqr = Math.abs(Math.pow(height / 100, 2));
});
weightInputEl.addEventListener('input', function (e) {
const weight = Number(e.target.value);
});
</script>