var income = parseInt(prompt('Please enter your income
here.'))
switch (income){
case (income < 9701):
console.log ('Your tax rate is 10%');
break;
case (income > 9700 && income <= 39475):
console.log('Your tax rate is 12%');
break;
case (income > 39475 && income <= 84200):
console.log('Your tax rate is 22%');
break;
case (income > 84200 && income <= 160725):
console.log('Your tax rate is 24%');
break;
case (income > 160725 && income <= 204100):
console.log('Your tax rate is 32%');
break;
case (income > 204100 && income <= 510300):
console.log('Your tax rate is 35%');
break;
case (income >= 510300):
console.log('Your tax rate is 37%');
break;
default:
console.log('Please enter a valid income')
}
Why does this code keep logging the "default" value to the console? If I put an equals sign in the case, i.e. case (income = 9700) and input 9700 then it logs ('Your tax rate is 10%') When I use greater/less than or equal to operators the code goes to default.