Commits (2)
......@@ -32,12 +32,17 @@
</div>
<!-- include prototypes here -->
<script src="./js/extra.js"></script>
<script src="./js/car.js"></script>
<script>
function generateCar(image, make, model, description, price, category, year, mileage, extras) {
//Create an array of Extra instances based on Extras names and prices
// Create a new Car instance
const extraInstances = extras.map(extra => new Extra(extra.name, extra.price));
return new Car(image, make, model, description, price, category, year, mileage, extraInstances);
}
function showHideExtra(btn,elt,car) {
......
function Car(image, make, model, description, price, category, year, mileage, extras) {
this.image = image;
this.make = make;
this.model = model;
this.description = description;
this.price = price;
this.category = category;
this.year = year;
this.mileage = mileage;
this.extras = extras;
}
Car.prototype.generateImage = function(elt) {
const img = document.createElement('img');
img.src = this.image;
img.alt = this.make + " " + this.model;
img.classList.add('card-img-top');
elt.appendChild(img);
};
\ No newline at end of file
function Extra(name, price) {
this.name = name;
this.price = price;
}
\ No newline at end of file