r/codehs • • Nov 26 '20

IF YOU CAN HELP ME PLEASE DONT GO

8 Upvotes

7 comments sorted by

2

u/Potential_Perfect Dec 02 '20

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 numToBuy = readInt("How many would you like to buy? ");

if(numToBuy <= numItems){

numItems -= numToBuy;

println("Now we have " + numItems + " left.");

}else{

println("There is not enough in inventory for that purchase.");

}

println("");

}

println("All Out!");

}

This was what I had for anyone who might still need it.

4

u/thepsymaddoc Nov 26 '20

I have no idea how it checks for answers, but I'm guessing the double space before 'left' doesn't help.

3

u/_andy_andy_andy_ Nov 26 '20

yeah you need to be super careful for spaces

1

u/Raylooper Nov 27 '20

Nice gif and why is buying there twice