1- // Use terminal commands to see what happens when we call Astronaut but do not pass in 3 arguments.
1+ // // Use terminal commands to see what happens when we call Astronaut but do not pass in 3 arguments.
2+ // // console.log(Astronaut);
3+ // // Astronaut();
24
3- // Next, set default values for 1 or more of the parameters in constructor.
5+ // // Next, set default values for 1 or more of the parameters in constructor.
46
5- class Astronaut {
6- constructor ( name , age , mass ) {
7- this . name = name ;
8- this . age = age ;
9- this . mass = mass ;
10- }
11- }
7+ // class Astronaut {
8+ // constructor(name = 'Who?' , age, mass = 100 ){
9+ // this.name = name;
10+ // this.age = age;
11+ // this.mass = mass;
12+ // }
13+ // }
1214
13- let tortoise = new Astronaut ( 'Speedy' , 120 ) ;
15+ // let tortoise = new Astronaut('Speedy', 120);
1416
15- console . log ( tortoise . name , tortoise . age , tortoise . mass ) ;
17+ // console.log(tortoise.name, tortoise.age, tortoise.mass);
1618
17- // What happens if we call Astronaut and pass in MORE than 3 arguments? TRY IT!
19+ // // What happens if we call Astronaut and pass in MORE than 3 arguments? TRY IT!
20+ // console.log(tortoise.name, tortoise.age, tortoise.mass, tortoise.color);
21+ // console.log(Astronaut);
22+ // console.log(tortoise);
23+ class Car {
24+ constructor ( make , model , year , color , mpg ) {
25+ this . make = make ;
26+ this . model = model ;
27+ this . year = year ;
28+ this . color = color ;
29+ this . mpg = mpg ;
30+ }
31+ }
32+ let myCar = new Car ( 'Chevy' , 'Astro' , 1985 , 'gray' , 20 ) ;
33+ console . log ( typeof myCar . year ) ;
0 commit comments