Trying to figure out how to convert a date that is in the form of a string into a date that calculations can be run on. See below.
function PerishableFood(name,lastBuyDate,quantity, expirationDate) {
this.item = name;
this.buyDate = lastBuyDate;
this.quantity = quantity;
this.expireDate = expirationDate;
}
var milk = new PerishableFood('1% Milk','07/05/2017',1, '07/17/2017');
var butter = new PerishableFood('Test', '07/05/2017',2,'8/30/2017');
I know how to transform dates this way (see below) but the above are strings within an object from a user input so I am not sure how to transform them.
var date1 = '01/12/2018';
var date1 = new Date(date1);
Sorry if this is super easy not an expert yet in JS.