//create function function getMilk(money, costPerBottle) {//enclose all the instructions console.log("leaveHouse"); console.log("moveRight"); console.log("moveRight"); console.log("moveUp"); console.log("moveUp"); console.log("moveUp"); console.log("moveUp"); console.log("moveRight"); console.log("moveRight"); //numOfBottles = however much money you put in () and divide by 1.5, rounded down to the nearest whole number console.log("buy " + calcBottles(money, costPerBottle) + " bottles of milk"); console.log("moveLeft"); console.log("moveLeft"); console.log("moveDown"); console.log("moveDown"); console.log("moveDown"); console.log("moveDown"); console.log("moveLeft"); console.log("moveLeft"); console.log("enterHouse"); return calcChange(money, costPerBottle) ; } function calcBottles(startingMoney, costPerBottle) { let numberOfBottles = Math.floor(startingMoney / costPerBottle); return numberOfBottles; } function calcChange(startingMoney, costPerBottle) { let change = startingMoney % costPerBottle; return change; } //call the function console.log("Hello Alana, here is you " + getMilk(5, 1.5) + " change.");
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter