JSFiddle - React, Tailwind, and code Playground
by Alex Fogarty
JavaScript
function car(make, model, year, miles) {
this.make = make;
this.model = model;
this.year = year;
this.miles = miles;
}
var cadi = car("GM", "Cadillac", "1955", "9000");
var fiat = car("Fiat", "500", "1959", "9500");
var chevy = car("Chevy", "Malibu", "1960", "10000");
function dreamCar(insertedCar) {
if (insertedCar.miles > 10000) {
return false;
} else if (insertedCar.year > 1960) {
return false;
} else {
return true;
}
}
var buyThatCar = dreamCar(cadi);
if (buyThatCar) {
alert("You gotta check out this " + insertedCar.make + " " + insertedCar.model);
} else {
alert("You should really pass on the " + insertedCar.make + " " + insertedCar.model);
}
dreamCar(cadi);