Need help with JavaScript for calculator

I’m trying to build a calculator like on this website:

https://ihararepricecheck.com/mobile-money-charges-calculator/

A sample of the JavaScript I came up with is this:

(function(){
if(100<fieldname2 && fieldname2 <= 300) return 2.67;
if(300<fieldname2 && fieldname2 <= 600) return 1.97;
})()

However the JavaScript is not returning any results. Can you please check what’s wrong with my code.

In JavaScript you don’t have to use HTML entities like & < etc. They’re required when you want to write such signs inside of HTML.

In JavaScript however, you simple would write:

(function(){
if(100 < fieldname2 && fieldname2 <= 300) return 2.67;
if(300 < fieldname2 && fieldname2 <= 600) return 1.97;
})()

Wow! Thanks so much it worked. You a genius mate. Cheers!