When I write onto the document the object comes out as undefined and I don't know why. Any help you be greatly appreciated. P.S I'm relatively new to JS so I am still learning.
function car(make, model, year, color, passengers, convertible, mileage) {
this.make = make;
this.model = model;
this.year = year;
this.color = color;
this.passengers = passengers;
this.convertible = convertible;
this.mileage = mileage;
}
var carParams = {
make: "Toyota",
model: "Prius",
year: 2012,
color: "red",
passengers: 1,
convertible: false,
mileage: 3403,
};
var toyota = new car(carParams);
document.write(
"The " +
toyota.make +
" " +
toyota.model +
" is a really fast car because it is " +
toyota.color +
"."
);