1class Person {
2 constructor(name) {
3 this.name = name;
4 }
5 introduce() {
6 console.log(`Hello, my name is ${this.name}`);
7 }
8}
1function Person(firstName, lastName) {
2 this.firstName = firstName;
3 this.lastName = lastName;
4}
5
6const member = new Person('Lydia', 'Hallie');
7Person.getFullName = function() {
8 return `${this.firstName} ${this.lastName}`;
9};
10
11console.log(member.getFullName());
12
1// Let's make a function that will accept parameters for our vehicle
2function Car(maker, model, color, tireSize) {
3// Now we will set the paramaters equal to the different attributes of the car
4 this.maker = maker;
5 this.model = model;
6 this.color = color;
7 this.tireSize = tireSize;
8// Next we'll make a method that will give a dynamic description of our car
9 this.description = function() {
10
11 return "My car is a " + color + " " + maker + " " + model + " with " + tireSize + " inch tires."
12
13 }
14
15}
16// Now let's make a new car. I want the car to have these attributes:
17let car1 = new Car("Kia", "Soul", "white", 15);
18// Now we can print the description of out new vehicle to the console
19console.log(car1.description());
20
21// OUTPUT: My car is a white Kia Soul with 15 inch tires.