1. Create a constructor function named Car that will accept the following parameters and set them to properties of the same name. (Hint: Use the keyword this ). make model year color 2. Inside the constructor function set the property kmTravelled a value of 0. 3. Create a function on the Car prototype named drive . This function will accept a parameter named distance and inside the function will update the kmTravelled property on our object by adding the passed in value of distance. 4. Add a friendly console message to the drive method displaying the vehicle’s year, make, model and distance travelled. 5. Use the Car constructor function to create a new instance of Car and save it to a variable. Pass it values of a car you own or would like to own. 6. Create another Car object and save it to a variable. Set the values to a car that belongs to a family member or friend. 7. Execute the drive method a few times on your newly created cars (don’t forget to pass a distance). Sample output: The 1969 Ford Mustang has travelled 123km. The 2014 Chevy Cruze has travelled 112km. The 2014 Chevy Cruze has travelled 155km. The 1969 Ford Mustang has travelled 453km. The 1969 Ford Mustang has travelled 698km. The 2014 Chevy Cruze has travelled 598km.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

1. Create a constructor function named Car that will accept the following parameters and set them to properties of
the same name. (Hint: Use the keyword this ).
make
model
year
color
2. Inside the constructor function set the property kmTravelled a value of 0.
3. Create a function on the Car prototype named drive . This function will accept a parameter named distance
and inside the function will update the kmTravelled property on our object by adding the passed in value of
distance.
4. Add a friendly console message to the drive method displaying the vehicle’s year, make, model and distance
travelled.
5. Use the Car constructor function to create a new instance of Car and save it to a variable. Pass it values of a car
you own or would like to own.
6. Create another Car object and save it to a variable. Set the values to a car that belongs to a family member or
friend.
7. Execute the drive method a few times on your newly created cars (don’t forget to pass a distance).
Sample output:
The 1969 Ford Mustang has travelled 123km.
The 2014 Chevy Cruze has travelled 112km.
The 2014 Chevy Cruze has travelled 155km.
The 1969 Ford Mustang has travelled 453km.
The 1969 Ford Mustang has travelled 698km.
The 2014 Chevy Cruze has travelled 598km.

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education