Creating a Bracketed Sales Commission Calculator with Javascript

I’m trying to create a calculator using javascript syntax for a realtor client. She wants to use it to show her clients what her commission amount would be. Here’s the parameters she gave me. They are bracketed (like income taxes):

  • 0.575% up to $100,000
  • any amount in excess of $100k, up to $1m is charged at 0.5%
  • any amount in excess of $1m is charged at 0.25%

Therefore:

  • The first $100k is $575
  • The first $1m is $5075 ($575 for the $100k plus $4500 for the next $900k)

Here is my code, where the input is x.

(function(){
    if(x <= 100000) return x*0.00575;
    if(x > 100000 && < 1000000) return ((x-100000)*0.005+575);
    if(x >= 1000000) return ((x-1000000)*0.0025+5075);
})();

Is this correct? What have I done wrong?


Source: stackoverflow-javascript