The error of missing operand before < 178651 is already found, but in case you want your code to have less potential errors, i suggest a light refactoring procedure.
Using else if will be more efficient. Once found a block that corresponds to a given entry value, the program will stop checking other conditions. Moreover, you will have to specify just those values which divides your range (your "milestones"), instead of repeating them like entry < 8701 followed by entry > 8700. Finally, it wil fix other bug which is printing tax_owed = ..something like 140000.. when you enter 99999.
Changing the condition of the loop (introducing a boolean variable) would be more readable.
I'm not a tax man at all, but are you sure you want to add tax_owed += entry; ? I mean, do i really owe $10130.5 when declaring $10000? In any case, it will be more readable to have 1 line instead of 2: tax_owed = entry + 17442 * 0.28; // but do you really add 'entry'?.
So, the code will be something like this:
continueEntering = true;
while ( continueEntering ) {
tax_owed = 0;
entry = prompt("Enter taxable income as a valid number\n" + "Or enter 99999 to end entries", 99999);
entry = parseInt(entry);
if (entry == 99999) {
continueEntering = false;
} else if (entry < 0){
alert("Please enter a positive number");
} else if (entry <= 8700){
tax_owed = entry * 0.10;
} else if (entry <= 35350){
tax_owed = 870 * 0.15 + entry;
} else if (entry <= 85650){
tax_owed = 4867 * 0.25 + entry;
} else if (entry <= 178650){
tax_owed = 17442 * 0.28 + entry;
} else if (entry <= 388350){
tax_owed = 43482 * 0.33 + entry;
} else {
tax_owed = 112683 * 0.35 + entry;
}
alert("Tax owed is " + tax_owed);
}
As said in comments, it's really better not to use the values themselves inside the body of your loop. It will be way easier to change one day those values, if they are stored in variables. here you can use 2 arrays. You can call them, say, thresholds[] and tax_percentage[], or whatever (you know it better than me). The good thing of using arrays is that you'll be able to replace the sequence of if statements by just one for loop inside your original while loop.
================ UPDATE ====================
Here is how you can refactor the above code to use a for loop instead of lots of if.
continueEntering = true;
while ( continueEntering ) {
tax_owed = 0;
exitValue = 99999;
tax_threshold = [ 0, 8700, 35350, 85650, 178650, 388350 ];
tax_rate = [ 0.10, 0.15, 0.25, 0.28, 0.33, 0.35 ];
additional_tax = [ 0, 870, 4867, 17442, 43482, 112683 ];
entry = prompt("Enter taxable income as a valid number\n" +
"Or enter " + exitValue + " to end entries", exitValue);
entry = parseInt(entry);
if (entry == exitValue) {
continueEntering = false;
} else if (entry < 0){
alert("Please enter a positive number");
} else {
for( i = tax_threshold.length-1; i >= 0; i-- ) {
if ( entry > tax_threshold[i] ) {
tax_owed = entry - tax_threshold[i];
tax_owed *= tax_rate[i];
tax_owed += additional_tax[i];
break;
}
}
}
alert("Tax owed is " + tax_owed.toFixed(2));
}