Message from JavaScript discussions

April 2017

— Ah wait

— 

Alert("Welcome in Matteo's Store! Join in and get something!");
var money = 300;
var item1 = {a: 5};
var buyItem1 = true;
function buy(money, item1)
{
if(buyItem1===true)
{
money = money - item1;
console.log(money);
}
}

buy(money, item1);

— Like this?

— And you can replace if(buyItem1===true) with if(buyItem1) and money = money - item1; could be money -= item1; i think

Message permanent page

— Yes

— Ah ok

— No

— The challenge is calculating which denominations and how many to give back as change

— Because your item1 is an object

— Yes

— Money - item1

— Ah wait