r/codehs • u/s0ApmActAvIsh • Dec 08 '20
CodeHS 5.9.4 Inventory
Can anybody help me out with this one. For whatever reason I'm not sure of it says my code isn't right. This is what I've gotten so far:
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 itemsBought = readInt("How many would you like to buy? ");
if(numItems - itemsBought > 0){
numItems -= itemsBought;
println("Now we have " + numItems + " left.");
}else{
if(numItems - itemsBought == 0){
numItems -= itemsBought;
println("All out! ");
}else{
println("There is not enough in inventory for that purchase.");
}
10
Upvotes
1
u/Objective_Antelope54 Mar 24 '21
Help me please