Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Creating a car object for chauffer website

I am creating a chauffeur website and for the page that has the cars on it I am thinking that I should make a car class with a car object in it and then if the admin wants to add a car they simply just plug in the values. Is this the correct way to go about? Would I also be able to use a picture as an attribute? I have been getting a little confused about how to go about it so far. My initial thought was to create a div with a picture in it and some text along side it explaining about the car and a button to redirect to the booking page. However I thought this would be repeating itself, and not following the D.R.Y way of programming. Any suggestions on how to go about this?

1 Answer

What are you trying to accomplish? What I mean by that is, for now not how to, but what do you want the page to do? I Is what you want a page of cars that people can click on and be redirected to a booking page?

Thank you for the reply.

Essentially yes, that is what I want it to do in the end. But for now I am just trying to create (in a mobile first view) a page that consists of a list of cars with some description of the car and then a button that links it to a booking page. At the moment I have done this

I plan to add media queries later on so that I can make the list float right of the car image when the site is in a bigger screen resolution.

Okay, it sounds like to me all you need to do is use an img and a unordered list nested inside of a div. I don't think you need an JS object for this. why do you want to go that route?

Thanks, that is what I have done originally will stick with that. I thought maybe using a object would be better to maintain later on when adding new cars.