Lesson 116 – Complete 2020 Web Development Bootcamp

Lesson 116 – Parameters and Arguments

The challenge in this lesson was to adjust the given code to take an input of money in the function and to console log the amount of bottles that can be purchased with the amount of money input.

This is my solution.

function getMilk(money) {   
  var bottleCost = 1.5
  var totalBottles = Math.floor(money / bottleCost)
  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");
  console.log("You have $" + money + ". You can buy " + totalBottles + " 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");
}

getMilk(8);