Stuck on temperature converter logic ..I don't wanna use arrow function right in the logic

I have been working on a temp converter application but my logic somehow does not work correctly although I console it still it’s not throwing any error neither show an output… I need immediate help…
here’s my code GitHub - naima-shk/Temperature-Convertor

You’re not seeing anything because when a form is submitted, the browser reloads the page. To prevent that, you can pass the event object to your tempCalc function and call event.preventDefault. But first you’d have to change the way you’re adding the event handler, it’s best not to do that in the HTML, but in your JS file like this:

document.querySelector('form').addEventListener('submit', tempCalc)

This way, the event object gets passed automatically into your function, where you can use it:

const tempCalc = (event) =>{
    event.preventDefault() //this line must come first in your function
}

Once you fix that, you’ll at least see your error messages and logs. One problem for instance is that this is undefined:
unit.options[tempSelected.selectedIndex].value;

That line indicates that something is missing from your code (the place where you define the unit variable). In any case, it should be easier for you to debug now.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.