I am working on this code long time and still can't figure out what is wrong here... when I click on check code it says that:
- If I tried to remove 25 items, there should still be 20 items left in the inventory
- If I remove 20 items, you should say "All Out!"
but my code is working in both situations. So here is my code:
var STARTING_ITEMS_IN_INVENTORY = 20;
function start(){
var numItems = STARTING_ITEMS_IN_INVENTORY;
while(numItems>0 ){
println("We have "+numItems+" items in inventory");
var number=readInt("How many would you like to buy?");
numItems-=number;
if(numItems>0){
println("Now we have "+numItems+" left");
println("");
}
if(numItems==0){
println("");
println("All Out!");
}else if(numItems<0){
println("There is not enough in inventory for that purchase");
}
}
}
Please help me with this problem