@@ -1114,10 +1114,10 @@ and you can chain further class methods onto it.
1114
1114
** Bad:**
1115
1115
``` javascript
1116
1116
class Car {
1117
- constructor () {
1118
- this .make = ' Honda ' ;
1119
- this .model = ' Accord ' ;
1120
- this .color = ' white ' ;
1117
+ constructor (make , model , color ) {
1118
+ this .make = make ;
1119
+ this .model = model ;
1120
+ this .color = color ;
1121
1121
}
1122
1122
1123
1123
setMake (make ) {
@@ -1137,20 +1137,18 @@ class Car {
1137
1137
}
1138
1138
}
1139
1139
1140
- const car = new Car ();
1140
+ const car = new Car (' Ford ' , ' F-150 ' , ' red ' );
1141
1141
car .setColor (' pink' );
1142
- car .setMake (' Ford' );
1143
- car .setModel (' F-150' );
1144
1142
car .save ();
1145
1143
```
1146
1144
1147
1145
** Good:**
1148
1146
``` javascript
1149
1147
class Car {
1150
- constructor () {
1151
- this .make = ' Honda ' ;
1152
- this .model = ' Accord ' ;
1153
- this .color = ' white ' ;
1148
+ constructor (make , model , color ) {
1149
+ this .make = make ;
1150
+ this .model = model ;
1151
+ this .color = color ;
1154
1152
}
1155
1153
1156
1154
setMake (make ) {
@@ -1178,10 +1176,8 @@ class Car {
1178
1176
}
1179
1177
}
1180
1178
1181
- const car = new Car ()
1179
+ const car = new Car (' Ford ' , ' F-150 ' , ' red ' )
1182
1180
.setColor (' pink' )
1183
- .setMake (' Ford' )
1184
- .setModel (' F-150' )
1185
1181
.save ();
1186
1182
```
1187
1183
** [ ⬆ back to top] ( #table-of-contents ) **
@@ -1945,8 +1941,8 @@ class Alpaca {}
1945
1941
const DAYS_IN_WEEK = 7 ;
1946
1942
const DAYS_IN_MONTH = 30 ;
1947
1943
1948
- const songs = [' Back In Black' , ' Stairway to Heaven' , ' Hey Jude' ];
1949
- const artists = [' ACDC' , ' Led Zeppelin' , ' The Beatles' ];
1944
+ const SONGS = [' Back In Black' , ' Stairway to Heaven' , ' Hey Jude' ];
1945
+ const ARTISTS = [' ACDC' , ' Led Zeppelin' , ' The Beatles' ];
1950
1946
1951
1947
function eraseDatabase () {}
1952
1948
function restoreDatabase () {}
0 commit comments