I'm learning JavaScript (with the aid of online tutorials) and can't figure out where I messed up. This is what I have and where the problem seems to be:
<script type="text/javascript">
var apples = 10;
alert('There are currently ' + apples + ' apples!');
var toss = prompt('How many apples would you like to throw at the doctor?', '0');
var thrown = parseInt(toss);
if(thrown > apples){
alert('Sorry, but there are not that many apples. You can not throw ' + thrown + ' apples!');
} else { if(apples - thrown = 1){
alert('Now there is only one apple left to throw!');
} else {apples -= thrown;
alert('Now there are only ' + apples + ' apple(s) left to throw!');
}
}
</script>
Is there some weird rule about having if/else statements within other if/else statements? Or did I mess up in my ignorance elsewhere?
Any help would be greatly appreciated.